3

Is there any environment or internal variable in MATLAB that holds the name of the current executing function or workspace?

If not, what would be an easy way of defining this variable for every script/function within a toolbox or folder?

Having such variable always in the workspace would be helpful for debugging, for example:

  1. One could easily trace the execution of user-defined functions in the command window, e.g. disp(name_of_running_function);

  2. One could conveniently save the (full or partial) memory state of running functions to disk, e.g. save(name_of_running_function, 'all');

Thanks

1 Answer 1

6

mfilename: See here. Found through Google.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I can't believe I missed that!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.