MATLAB Function Reference Previous page   Next Page
mfilename

Return name of currently running M-file

Syntax

Description

mfilename 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 nonmethod, it yields the empty string.

Remarks

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 an M-file, use dbstack with an output argument.

See Also

dbstack, function, nargin, nargout, inputname


Previous page  mexext mget (ftp) Next page

© 1994-2005 The MathWorks, Inc.