Hi everyone,
I want to add several functions from a single .m file. Is this possible without actually having to create an individual m file for each function?
Hi everyone,
I want to add several functions from a single .m file. Is this possible without actually 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();
It's possible (at least at 2010a). You have just to finish each function by 'end' statement. Like:
function a
...
end
function b
...
end
Actually, MatLab supports (at least) 4 types of .m files :