I noticed that the function "unix" acts differently, mainly in regards to my PATH variable, depending on whether I start MATLAB from the application or from Terminal.
When I start from Terminal, I get the same $PATH that I would in that Terminal window:
>> unix('echo $PATH')/usr/local/fsl/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/Applications/Inkscape.app/Contents/Resources/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
When I start from the Application, it gets a very basic PATH from… somewhere:
>> unix('echo $PATH')/usr/bin:/bin:/usr/sbin:/sbin
I can change my path, but it reverts the next time I use the unix function:
>> unix('source /Users/pcrutchl/.bash_profile; echo $PATH')/usr/local/fsl/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/Applications/Inkscape.app/Contents/Resources/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbinans = 0>> unix('echo $PATH')/usr/bin:/bin:/usr/sbin:/sbinans = 0
(To be clear: changing the path manually every time, or even initially, isn't really a solution, just an exploration of the behavior. If I could put something in startup.m to fix it, that would be fine.)
Is this known behavior? Is there a good way to get the application MATLAB to behave like the MATLAB launched from command line?
Best Answer