Sometimes when you install Matlab program (Mathworks Inc.) you may notice that the “m” files are not associated with the Matlab program. The file may look something like the following image and as you notice there is no specific icon associated to that.
When you double-click on the file you may see the following message box you will receive the famous error in windows that “windows cannot open this file”. You have to associate the m files to matlab program however if you take this approach every time you double click on a m or mat file you will run the matlab program in a new instance and the file will not be opened in the editor of matlab program which is currently open.
To open m files with Matlab program you can simply run the software and in the command box type the following commands:
clc cd([matlabroot '\toolbox\matlab\winfun\private']); fileassoc('add',{'.m','.mat','.fig','.p','.mdl',['.' mexext]}); disp('Changed Windows file association. MAT-files are now associated with MATLAB.')
After hitting “Enter” on your command windows you will see the following message:
Changed Windows file association. MAT-files are now associated with MATLAB.
In the next step you need to restart your computer and the problem would be solved. Whenever you double-click on the m files you will run the matlab program automatically.