Mike on the MATLAB Desktop
March 1st, 2010
Starting MATLAB from the Mac OS X Finder
I’d like to welcome back guest blogger Ken Atwell for his second in a two part series of accessing MATLAB from the Macintosh OS X environment. This week he writes about opening a MATLAB file from the Finder.
MATLAB source files have the .m extension and the Finder should have an association between MATLAB and files with a “.m” extension. However, if you try to open a MATLAB source file by double-clicking in the Finder, you may get one of these unexpected behaviors:
- Rather than starting MATLAB, you may get a report of a crash and an offer to reopen the application. Should you choose to reopen, you will again get a crash. This is happening because MATLAB, not a required starter application, is being invoked by the Finder. Refer to my previous post for a discussion of the MATLAB starter app and the reasons why this crash happens.
- Rather than starting MATLAB, Xcode (Apple’s software development environment) may start. In an unfortunate coincidence, the .m extension is also used by Xcode for Objective-C files (with “m” indicating a file containing Objective-C methods). If you have Xcode installed on your Mac, it is likely that double-clicking a MATLAB source file will start Xcode instead of MATLAB.
Both of these problems can be addressed with the same procedure: To open a MATLAB source file from the Finder on a one-off basis, you can Control-click (or right-click) the file and use the Open With menu. On Snow Leopard, you will see two MATLAB choices, one called “MATLAB_R2009b” (the exact choice depends on the version of MATLAB you have installed) and the other one simply “MATLAB” (Figure 1). Choose “MATLAB_R2009b” (the starter application) and not “MATLAB”. Choosing “MATLAB” will result in a crash as discussed above.
Figure 1: Using “Open With” to launch MATLAB instead of Xcode
Suppose you wish to launch MATLAB every time you double-click any file with the .m file extension? The Mac OS X Finder allows you to change the default double-click behavior:
- Control-click any MATLAB source file (with a “.m” extension) and then select Get Info.
- In the Info window, expand the Open With section and select “MATLAB_R2009b”… again, not “MATLAB” (Figure 2).
- Click Change All… and then confirm that all files with the .m extension should be opened with “MATLAB_R2009b”.
Figure 2: Changing the default Open behavior for MATLAB source files
MATLAB should now start without issue whenever you double-click a MATLAB source file in the Finder.
Have you figured out any other OS X shortcuts or tricks that have simplified your workflow? Chime in below!
By
Michael Katz
Mike is a developer on the MATLAB Mobile team. When not describing himself in the third person, biking, homebrewing, or rooting for the home team, he's busy trying to make the world a better place for programming.
13:37 UTC |
Posted in Mac |
Permalink |
5 Comments »
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.
Leave a Reply
|
After downloading a new version of MATLAB next time, I wonder if I will remember to change my “Open with” setting for MATLAB source files.
Desired behavior: double click a .m file in the Finder, it open matlab and opens the file in the editor.
Your advice doesn’t work for me. If matlab 2009b is not running, it will start. After it starts the file I double clicked does not open in the editor. If matlab 2009b is already running, it becomes the foreground app (after a delay caused by the starter-app opening), but the file I double clicked does not open in the editor.
It doesn’t seem like this should be difficult, so I’d love some help.
I have the same problem as mrhill. I’m running Matlab R2009b on an imac. A solution would be greatly appreciated. Thanks.
@mrhill, @Peter,
I will take a look into it. (To get dedicated resources for diagnosing the issue and the ability to track it – contact tech support).
@mrhill, @Peter,
I checked in with our developer, and this functionality in MATLAB is currently broken on Mac OS X 10.6 Snow Leopard. The workaround is to start MATLAB first, and then open files from the Finder. Alternatively, you can drag the file icon to the StartMATLAB icon in the Dock or in the Application folder.