Quantcast

Documentation Center

  • Trial Software
  • Product Updates

mfilename

File name of currently running function

Syntax

mfilename
p = mfilename('fullpath')
c = mfilename('class')

Description

mfilename returns a string containing the file name of the most recently invoked function. When called from within the file, it returns the name of that file. This allows a function to determine its name, even if the file name has been changed.

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 yields the empty string.

More About

expand all

Tips

If 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 a MATLAB® function file, use dbstack with an output argument.

See Also

| | | |

Was this topic helpful?