mardi 21 novembre 2017

How can I find the file extension of the currently running code?

MATLAB provides the mfilename function. It returns the name of the file where the function was invoked, but unfortunately, it returns the file name without the 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 had a look at the fileparts function but it is not useful either because it only parses the string that you provide.

I am developing a piece of code has a different behavior based on the file extension. So for instance, it needs to know whether the extension of the file is .m or .p at run time.

You can check the list of extensions associated with MATLAB here.

How can I do it?





Aucun commentaire:

Enregistrer un commentaire