Here is one…
I have a main()-function in main.m, and the file includes a subfunction()-function, like:
function mainb = subfunction(c);f = external(c);function b = subfunction(c)b = c^2;end
and I have an external()-function in external.m, like
function d = external(e)d = subfunction(e)*2;
I would like to keep the external()-function in this separate file, but I would like it to be able to use sub-functions in the main file. Now I would have expected, since the main.m is initiated that all subfunctions within it was then "declared" globally, but it turns out that the external function can't call the subfunction, even if it has been called before the external function calls it.
Is there a work-around?
Why? I share the main() with other users, and develop the external() until some point of sharing. Until then I would like to keep it private, but still being able to exploit subfunctions. Alternatively I would need to copy all subfunctions in main() that I need into the external.m or into separate files… But when I share stuff, it is sometimes nice not to send hundreds of files around…
Best Answer