MATLAB provides the mfilename function. It returns the name of the file in which the function was called, but, unfortunately, it returns the name of the file without extension .
So, for example, if we have a file called myfile.m , and we call mfilename inside the file, it will return the string 'myfile' , but not 'myfile.m'
I also looked at the fileparts function, but this is not useful either because it only parses the string you provide.
I am developing a piece of code that has different behavior based on the file extension. So, for example, he needs to know if the file extension is .m or .p at runtime .
You can check the list of extensions related to MATLAB here .
How can i do this?
reflection matlab file-extension
codeaviator
source share