开发者

how to add multiple functions in matlab

I want to add several functions from a single .m file. Is this possible without actu开发者_运维技巧ally having to create an individual m file for each function?


For later versions of Matlab that support the classdef keyword, I recommend adding the functions as static methods to a class and then calling them from an instance of that class. It can all be done with one .m file:

classdef roof
  methods (Static)
    function res = f1(...)
        ...
    end
    function res = f2(...)
        ...
    end
  end
end

and you call them by

roof.f1();
roof.f2();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜