Set default startup folder to userprofile
조회 수: 11 (최근 30일)
이전 댓글 표시
Hi,
Whenever I open MATLAB, I get a prompt indicating it could not open the previous working directory, "/Users/User01/Documents/MATLAB and switching to /Users/Me/Documents/MATLAB" How can I get rid of this prompt? I've looked up how to create a startup.m file, but found nothing on what the contents should be or where to place it in macOS or the MATLAB application.
Thanks
Jason
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191040/image.png)
댓글 수: 1
Stephen23
2018년 6월 6일
편집: Stephen23
2018년 6월 6일
"I've looked up how to create a startup.m file, but found nothing on what the contents should be ..."
There is nothing special about startup.m apart from its name and location: it is just a normal script, it does not have any special requirements for what you have to write in it. You can put anything inside it, just like you would any other script. You didn't find any special requirements for its contents because it doesn't have any special requirements for its contents.
"...or where to place it in macOS or the MATLAB application"
The startup help states "Create a startup file in the userpath folder...", and at the bottom under the title "See Also" has a link to userpath. The userpath page explains that its default location for Mac platforms is $home/Documents/MATLAB, but it is possible that the userpath location was changed by your sysadmin or someone else. Obviously you can check this easily, just by reading the userpath help.
답변 (2개)
Stephan
2018년 6월 5일
편집: Stephan
2018년 6월 5일
Hi,
see here:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/188993/image.png)
-
Note that unless you include the file path in the following list, you will not be able to solve this problem. Matlab searches for files only in the specified folders:
-
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/188995/image.png)
-
All paths in the list will be used by matlab to find files / functions.
Best regards
Stephan
Stephan
2018년 6월 5일
편집: Stephan
2018년 6월 5일
Hi again,
write a script named
startup.m
and save it in one of the search paths of matlab. This script will be executed by matlab at every start. Then you could use the following code in order to add the "User"-folder with all sub-folders to the matlab search path:
addpath(genpath('YOUR_SUPERORDINATED_USER_PATH_NAME'))
This should work for new users too.
see also here:
and
Best regards
Stephan
댓글 수: 2
Stephan
2018년 6월 6일
편집: Stephan
2018년 6월 6일
I'm not familiar with the file structure on mac. Take the folder in which the different users are created and where their files are stored by matlab.
I guess it should be
Users
when i look at the paths in your question:
Users/User01/Documents/Matlab
and
Users/Me/Documents/Matlab
this will cause every subfolder of Users (and Users himself) to be added to the matlab searchpath every time matlab starts up. then the folders of new users are also automatically included. That should solve your problem.
Best regards
Stephan
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!