【发布时间】:2013-08-10 09:30:00
【问题描述】:
对于 MATLAB 中的对象,是否可以在不知道包含包的情况下调用相同类型的静态函数?现在,我发现引用它的唯一方法是使用Package.Whatever.staticfunction(),但我想通过让它独立于它所在的任何包运行来正确封装这个类。
我现在找到的解决方案是:
classdef Whatever
methods(Static)
function fig = staticfunction()
...snip...
end
end
methods
function obj = Whatever()
% Call Package.Whatever.staticfunction();
eval(sprintf('%s.staticfunction();', class(obj)));
end
end
end
但这似乎笨拙、缓慢且不正确。有更好的方法吗?
【问题讨论】:
标签: matlab matlab-class