0

I would like to have multiple functions in one .m file. Is this doable?

I tested with a file mytest.m that contains two functions.

function mytest()
    disp('my test');
end

function tst()
    disp('my test 2');
end

From another file, I can call the mytest function, but if I try to call tst, I get an error message saying tst is undefined.

devil0150
  • 1,350
  • 3
  • 13
  • 36
  • 1
    You cannot call [local functions](https://www.mathworks.com/help/matlab/matlab_prog/local-functions.html) from an external function. A class of [static methods](https://www.mathworks.com/help/matlab/matlab_oop/static-methods.html) may be more appropriate. – sco1 Mar 22 '17 at 13:31
  • 1
    This is possible when using [classes](https://www.mathworks.com/matlabcentral/answers/153441-call-a-function-inside-a-script-from-another-script). – Dev-iL Mar 22 '17 at 13:36

0 Answers0