MATLAB Answers

How do I associate file types with a certain application?

97 views (last 30 days)
I would like MATLAB files with the ".m" extension to open automatically with the MATLAB Editor/Debugger when I double-click them. I would also like MDL-files to open in Simulink when I double click them.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 7 Mar 2017
Some operating systems associate file extensions with specific programs/applications, and opens a file based on that association. Below are general instructions for changing these settings:
For Windows 8, Windows 10, and if the file extension is not in a list of file extensions:
1. Right click on any .m file in Windows and select Open With.
2. Select the More Apps option to show a full list of programs installed on your computer.
3. Select MATLAB and make sure the box at the bottom is checked that says "Always use this app to open .m files"
For Windows 7:
1. Right click on any .m file in Windows Explorer and select Open.
2. The above will show two options. Select the one that says "Select a program from a list of installed programs" and hit OK.
3. With the checkbox "Always use the selected program to open this kind of file" on, choose MATLAB as a program you want use to open .mat file. MATLAB.exe should be located at:
$MATLABROOT\bin\win64 (assuming this is on Windows 7 64-bit)
where $MATLABROOT is the MATLAB root directory on your machine, as returned by typing
matlabroot
at the MATLAB command prompt.
After the above steps, you should be able to see the .mat extension in the list besides other file extensions.
For Windows Vista:
1. From the Windows "Start" Menu, go to "Settings". Choose "Control Panel" and then open the "Default Programs" control panel.
2. Select "Associate a file type or protocol with a program".
3. Scroll down to file type you would like to associate and select it. For example, if you would like to associate your MATLAB script/function files with the MATLAB 7.4 (R2007a) Editor/Debugger, you would select "M File".
4. Select "Change Program".
5. In the "Open With" window, select the executable file for the application with which you would like to associate the ‘.m’ file type. For example, to open MATLAB script/function files with the MATLAB 7.4 Editor/Debugger, select the "meditor.exe" file in $MATLABROOT\bin\win32 where $MATLABROOT is the MATLAB root directory on your machine, as returned by typing
 
matlabroot
at the MATLAB command prompt.
If the executable is not listed, click on the "Browse" button and locate the executable.
6. Click the "OK" button.
7. Click the "Close" button in the "Folder Options" window.
For Windows XP and MATLAB 7.0 (R14) and later:
1. From the Windows "Start" Menu, go to "Settings". Choose "Control Panel" and then open the "Folder Options" control panel.
2. Click on the "File Types" tab.
3. Scroll down to file type you would like to associate and select it. For example, if you would like to associate your MATLAB script/function files with the MATLAB 7.4 (R2007a) Editor/Debugger, you would select "M File". If the file type you want does not exist, you can make a new type by clicking on the "New " button. Just add the "File Extension" and "Associated File Type" and Click OK.
4. Click on the "Change" button.
5. In the "Open With" window, select the executable file for the application with which you would like to associate the ‘.m’ file type. For example, to open MATLAB script/function files with the MATLAB 7.4 Editor/Debugger, select the "meditor.exe" file in $MATLABROOT\bin\win32 where $MATLABROOT is the MATLAB root directory on your machine, as returned by typing
 
matlabroot
at the MATLAB command prompt.
If the executable is not listed, click on the "Browse" button and locate the executable.
6. Click the "OK" button.
7. Click the "Close" button in the "Folder Options" window.
For Mac OSX 10.6:
1. Open a New Finder Window and browse to a file of the type you'd like to change the extension.
2. Click on the file. Go to File in the top left and select "Get Info".
3. Go to "Open With" and expand that section.
4. Click on the drop down and select the program you'd like this file type to be associated to.
5. Click on the "Change All" button and "Continue"
  1 Comment
Brendan Hamm
Brendan Hamm on 18 Apr 2016
There is also an issue where your Windows Registry may not allow you to choose a later version of MATLAB for file association. I found a nice File Exchange pick which will create a .reg file to solve this: matlab file association fix

Sign in to comment.

More Answers (2)

Abdul Mannan
Abdul Mannan on 8 Feb 2017
This answer is not useful for under windows 8 or MATLAB R2016b.

James Connor
James Connor on 19 Jan 2018
here is the solution:
download this script and run: File association fix
then open .reg file in folder which will be created
  1 Comment
Maria Jesus de la Puente
Maria Jesus de la Puente on 6 Jun 2019
I have matlab R2018b and whenever I double click in an .m file the system opens a new matlab window. I do not want this: I want that the system opens the .m file in the same window I am already using.
Following the tip above I dowloaded the zip file File association. fix and unzipped it, but I did not see any .reg file created.
Another question is: where in my computer should I dowload the zip file association.fix? I did in my MATLAB folder

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!