Is there a way to get the name of a local function that runs in Matlab?
Note: mfilename returns the name of the .m file, not the name of the local function.
mfilename
dbstack returns a structure with a full stack of function calls. To get information for a top-level function, use:
dbstack
S=dbstack fname=S(1).name
There is a page on the Matlab Central website that seems to answer your question. Here is the code they recommend using:
[ST,I] = dbstack; __PRETTY_FUNCTION__ = ST.name;
__PRETTY_FUNCTION must contain the name of the local function to be executed.
__PRETTY_FUNCTION