Is there a way to, from a .m file, determine the filename (including directory path) of that .m file?
S = dbstack(); S(1).file
You might have to use the -completenames option.
p = mfilename('fullpath')
mfilename() is right function to call. You can simply have this line in your .m file to get the file name.
P=mfilename;
mfilename does not include the extension, and thus cannot distinguish between .p and .m files.
mfilename without any option does not include the path as was specifically requested by the user.
0 Comments