MATLAB: Is there a function that retrieves the filename of the current script

filenameMATLAB

Is there a way to, from a .m file, determine the filename (including directory path) of that .m file?

Best Answer

S = dbstack();
S(1).file
You might have to use the -completenames option.