Amelio Vazquez-Reina
Amelio Vazquez-Reina

Reputation: 96284

Variable holding the name of executing function or script in MATLAB?

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

Upvotes: 3

Views: 437

Answers (1)

Jonas Heidelberg
Jonas Heidelberg

Reputation: 5024

mfilename: See here. Found through Google.

Upvotes: 6

Related Questions