- Right-click a .m file and click
- Click the
Open Withtab then click
Use custom commandand type the following into the field:
matlab -desktop -r "f=%f; cd(fileparts(f)); edit(f); clear f;"
Addthen select the radio button next to
- Close the property window.
If you'd like to know what that command does:
matlab: to run Matlab
-desktop: to run Matlab without using a terminal
-r: execute following matlab code when Matlab opens
f=%f: Save filename of file to open to variable
cd(fileparts(f)): change the current directory to file
edit(f): open file
clear f: delete the matlab variable