Where is startup.m supposed to be?

后端 未结 6 2020
旧时难觅i
旧时难觅i 2021-01-31 03:13

I\'ve been chasing the answer to this question in the MATLAB documentation for a long time...

For example, at the bottom of

http://www.mathworks.com/help/matlab/

6条回答
  •  别那么骄傲
    2021-01-31 03:19

    According to this page in the docs, you should create your own startup.m in the "startup directory" which, if you follow the link, leads to this page explaining the definition of "startup directory" in this context.

    You can retrieve this "startup directory" with the userpath function which returns, on my system:

    >> userpath
    
    ans =
    
    C:\Users\MYUSERNAME\Documents\MATLAB;
    

    Personally, I just set the "Start In" in the shortcut to whatever I want - but obviously this won't work if you're not on Windows; if you're not on Windows or prefer not to rely on the shortcut you should create a startup.m with a call to cd in whatever directory userpath returns.

    The docs also say you can modify the userpath function, if you so desire, or the matlabrc.m file in matlabroot/toolbox/local (but you can only do the latter if you're a MathWorks engineer or a system administrator, otherwise MathWorks will rain fiery hell down on you from above, or something...).

提交回复
热议问题