Search code examples
matlabmat-file

MATLAB-files with custom extensions


In MATLAB, I would like to be able to save (and re-open) MATLAB-files using a different extension than .mat (e.g. 'file.settings' / 'file.data' / etc.) so that, e.g., the file 'file.settings' is really a 'file.mat' in disguise.

How can this be accomplished?


Solution

  • You can directly specify the file extension when calling save. Use either of these forms:

    save filename.settings
    save('filename.settings')
    

    To load the file, since the extension is not known to Matlab, you must indicate that the format is actually that of a .mat file:

    load filename.settings -mat
    load('filename.settings','-mat')