필터 지우기
필터 지우기

Set default startup folder to userprofile

조회 수: 11 (최근 30일)
Jason Watkins
Jason Watkins 2018년 6월 5일
편집: Stephen23 2018년 6월 6일
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
  댓글 수: 1
Stephen23
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
Stephan 2018년 6월 5일
편집: Stephan 2018년 6월 5일
Hi,
see here:
-
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:
-
-
All paths in the list will be used by matlab to find files / functions.
Best regards
Stephan
  댓글 수: 1
Jason Watkins
Jason Watkins 2018년 6월 5일
Won't that make the problem worse? I'm thinking about the users that have yet to log in to macOS. I don't know their names and they don't have preexisting profiles. I cannot add them to that list. Unless it'll take a wildcard.
Thanks

댓글을 달려면 로그인하십시오.


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
Jason Watkins
Jason Watkins 2018년 6월 5일
So,
addpath(genpath('Documents/MATLAB'))
should work?
Stephan
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 CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by