Reputation: 96264
I have followed the instructions here with no sucess:
I export the following variable in .bashrc
:
export MATLAB_USE_USERPATH=1
I can verify the above loads correctly with echo $MATLAB_USE_USERPATH
before I run MATLAB.
I have also run the following lines from MATLAB:
userpath('reset')
userpath('clear')
userpath('/path/to/my/startup')
But still MATLAB starts in my home directory, and not in /path/to/my/startup
.
Is there anything else I need to do? Can I edit the startup
folder manually in matlab.prf
?
Thanks
Upvotes: 2
Views: 6315
Reputation: 297
There is a file called matopts.sh or matopts.cmd based on the operating system.
We have to change the value of a variable in the file so that when this file is called in the starting of matlab to set the environment it change the root folder to the value specified.
There are proper comments specified to help us customize the file.
Upvotes: 0
Reputation: 41
The easiest way is as follows: (assume your desired startup folder is : /home/matlab/myspace)
1- add this path to your paths using userpath(/home/matlab/myspace) and then savepath
2- create startup.m file with the following content
cd /home/matlab/myspace
3- put startup.m file in /home/matlab/myspace
That is it, you should startup in your desired folder.
Upvotes: 1
Reputation: 10511
Unfortunately, there is a bug in the documentation, and the correct environment variable name is MATLAB_USE_USERWORK
(i.e. ...WORK
, not ...PATH
). Make that change, and you should be all set!
Upvotes: 2
Reputation: 4787
I don't know the regular way to do this, but the easy way is just settings the userpath to your directory of personal scripts.
In that folder, you put a script startup.m
which contains:
cd /path/to/my/startup
It might not look pretty, but this allows you to change the directory depending on other factors. I have seen examples of people who get a prompt at startup that asks 'Which project are you working on?' and depending on their input some files are loaded, the direcotry is changed, etc. Personally, I load settings from different locations depending on what computer MATLAB is working on (home computer, personal computer at my university, computer rooms at university, ...)
edit: Perhaps just a small idea that might help you along with those variables: you can always try to edit the MATLAB start script for Linux (not startup.m
but the bash script returned by which matlab
in your shell).
Upvotes: 4