Possible Duplicate:
Is it possible to define more than one function per file in MATLAB?
In order to define a (not anonymous) function in MATLAB, you need to create a file with the same name as the function; e.g., a function called myfunc can be defined in a file myfunc.m as per:
function rtn = myfunc(arg)
% do some stuff
end
Suppose in this same file myfunc.m, I have also a sub-function, as in
function rtn = myfunc(arg)
% do some stuff
end
function rtn = mysubfunc(arg)
% do some other stuff
end
AFAIK, there is no way to access mysubfunc from execution happening anywhere outside of the subfunc.m file. I have been and continue to be annoyed by this little idiosyncrasy in MATLAB (R2010b). Am I wrong -- is there any way to call mysubfunc from outside myfunc.m?
Update: New question: Is there any good way to do this? or should I really just suck it up and keep on making more files?