{"id":364,"date":"2010-03-01T13:37:35","date_gmt":"2010-03-01T13:37:35","guid":{"rendered":"https:\/\/blogs.mathworks.com\/desktop\/2010\/03\/01\/starting-matlab-from-the-mac-os-x-finder\/"},"modified":"2010-03-01T13:37:35","modified_gmt":"2010-03-01T13:37:35","slug":"starting-matlab-from-the-mac-os-x-finder","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2010\/03\/01\/starting-matlab-from-the-mac-os-x-finder\/","title":{"rendered":"Starting MATLAB from the Mac OS X Finder"},"content":{"rendered":"<p><em>I&#8217;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.<\/em><\/p>\n<p>MATLAB source files have the <tt>.m<\/tt> extension and the Finder should have an association between MATLAB and files with a \u201c.m\u201d 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:<\/p>\n<ol>\n<li>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 <a href=\"https:\/\/blogs.mathworks.com\/community\/2010\/02\/08\/starting-matlab-from-the-os-x-dock\/\">previous post<\/a> for a discussion of the MATLAB starter app and the reasons why this crash happens.<\/li>\n<li>Rather than starting MATLAB, Xcode (Apple\u2019s software development environment) may start.  In an unfortunate coincidence, the .m extension is also used by Xcode for Objective-C files (with \u201cm\u201d 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.<\/li>\n<\/ol>\n<p>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 \u201cMATLAB_R2009b\u201d (the exact choice depends on the version of MATLAB you have installed) and the other one simply \u201cMATLAB\u201d (Figure 1).  Choose \u201cMATLAB_R2009b\u201d (the starter application) and not \u201cMATLAB\u201d.  Choosing \u201cMATLAB\u201d will result in a crash as discussed above.<\/p>\n<div align=\"center\">\n<strong>Figure 1: Using \u201cOpen With\u201d to launch MATLAB instead of Xcode<\/strong><br \/>\n<a  href=\"https:\/\/blogs.mathworks.com\/images\/desktop\/ken_atwell_starting_matlab_from_the_mac_os_x_finder\/finder_open_with.png\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/blogs.mathworks.com\/images\/desktop\/ken_atwell_starting_matlab_from_the_mac_os_x_finder\/finder_open_with_small.png\" alt=\"Use Open With to launch MATLAB instead of Xcode\"><\/a>\n<\/div>\n<p>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:<\/p>\n<ol>\n<li>Control-click any MATLAB source file (with a \u201c.m\u201d extension) and then select Get Info.<\/li>\n<li>In the Info window, expand the Open With section and select \u201cMATLAB_R2009b\u201d\u2026 again, not \u201cMATLAB\u201d (Figure 2).<\/li>\n<li>Click Change All\u2026 and then confirm that all files with the .m extension should be opened with \u201cMATLAB_R2009b\u201d.<\/li>\n<\/ol>\n<div align=\"center\">\n<strong>Figure 2: Changing the default Open behavior for MATLAB source files<\/strong><br \/>\n<a  href=\"https:\/\/blogs.mathworks.com\/images\/desktop\/ken_atwell_starting_matlab_from_the_mac_os_x_finder\/change_open_behavior.png\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/blogs.mathworks.com\/images\/desktop\/ken_atwell_starting_matlab_from_the_mac_os_x_finder\/change_open_behavior_small.png\" alt=\"Change default Open behavior for *.m files\"><\/a>\n<\/div>\n<p>MATLAB should now start without issue whenever you double-click a MATLAB source file in the Finder.<\/p>\n<p>Have you figured out any other OS X shortcuts or tricks that have simplified your workflow?  Chime in below!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;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&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2010\/03\/01\/starting-matlab-from-the-mac-os-x-finder\/\">read more >><\/a><\/p>\n","protected":false},"author":38,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[41],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/364"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/users\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=364"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/364\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=364"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=364"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}