如何在迭代时获取Methodlist?

时间:2015-10-26 10:01:37

标签: matlab

我想在特殊路径中遍历所有类和包。 之后,我想获得MethodList。

在命令窗口中,我可以使用以下内容并且工作正常:

a = ?ClassName;
a.MethodList(X);

现在我把它分成一个函数:

function s =  befehlsreferenz(path)
s = what(path); % list MATLAB files in folder

for idx = 1:numel(s.classes)
    c = s.classes(idx);
    b = ?c;
    b.MethodList(0);        
end
end

我收到错误 请求的输出太多。最有可能的原因是左侧有[],它有一个以逗号分隔的列表 扩张。 (第7行)中的错误b.MethodList(0);

调试时我可以看到:

c:1x1 cell ='Chapter' b:空0x0 meta.class

为什么b是空的?我怎样才能获得方法表?

1编辑:

这是一个示例类,也没有使用它。

classdef TestClass
    %TESTCLASS Summary of this class goes here
    %   Detailed explanation goes here

    properties
    end

    methods
        function [c] = hallo(a)
            c = 1;
        end
    end

end

1 个答案:

答案 0 :(得分:0)

在Matlab中与运算符斗争时,它通常是使用基础函数的最佳选择,即meta.class.fromname(c)

相关文档:http://de.mathworks.com/help/matlab/ref/metaclass.html

此外,似乎s.classes(idx);是一个单元格,使用单元格索引:s.classes{idx} ;