mfilename
Filename of currently running code
Description
mfilename returns a character vector
containing the name of the file in which the function call occurs. If called from
within the file, it returns the name of that file. This allows a script or function
to determine its name.
p = mfilename("fullpath") returns the full path and name of
the 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
nonmethod, it returns an empty character vector.
Examples
Tips
If you call
mfilenamewith any argument other than"fullpath"or"class", the function behaves as if you called it with no argument.if called from the command line,
mfilenamereturns an empty character vector.To get the names of the callers of a MATLAB® function file, use
dbstackwith an output argument.
Extended Capabilities
Version History
Introduced before R2006a