- Right-click a .m file and click
Properties - Click the
Open Withtab then clickAdd - Expand
Use custom commandand type the following into the field:
matlab -desktop -r "f=%f; cd(fileparts(f)); edit(f); clear f;"- Click
Addthen select the radio button next tomatlab. - 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 opensf=%f: Save filename of file to open to variable fcd(fileparts(f)): change the current directory to file f's directoryedit(f): open file f for editingclear f: delete the matlab variable f