|MATLAB Function Reference|
The name of the currently running M-file
returns a string containing the name of the most recently invoked M-file. When called from within an M-file, it returns the name of that M-file, allowing an M-file to determine its name, even if the filename has been changed.
p = mfilename('fullpath')
returns the full path and name of the M-file in which the call occurs, not including the filename extension.
c = mfilename('class')
in a method, returns the class of the method, not including the leading
@ sign. If called from a non-method, it yields the empty string.
mfilename is called with any argument other than the above two, it behaves as if it were called with no argument.
When called from the command line,
mfilename returns an empty string.
To get the names of the callers of an M-file, use
dbstack with an output argument.