Borrar filtros
Borrar filtros

Set default startup folder to userprofile

11 visualizaciones (últimos 30 días)
Jason Watkins
Jason Watkins el 5 de Jun. de 2018
Editada: Stephen23 el 6 de Jun. de 2018
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 comentario
Stephen23
Stephen23 el 6 de Jun. de 2018
Editada: Stephen23 el 6 de Jun. de 2018
"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.

Iniciar sesión para comentar.

Respuestas (2)

Stephan
Stephan el 5 de Jun. de 2018
Editada: Stephan el 5 de Jun. de 2018
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 comentario
Jason Watkins
Jason Watkins el 5 de Jun. de 2018
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

Iniciar sesión para comentar.


Stephan
Stephan el 5 de Jun. de 2018
Editada: Stephan el 5 de Jun. de 2018
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 comentarios
Jason Watkins
Jason Watkins el 5 de Jun. de 2018
So,
addpath(genpath('Documents/MATLAB'))
should work?
Stephan
Stephan el 6 de Jun. de 2018
Editada: Stephan el 6 de Jun. de 2018
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

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by