Reputation:
I installed matlab R13a a while ago. When it starts up the current working directory is the bin folder. But I don't want it to be so. How can I change the current folder so that when I run matlab it starts initially in that folder?
Upvotes: 1
Views: 548
Reputation: 2652
You might consider setting the startup directory to be the last directory from the previous MATLAB session by editing both startup.m
and finish.m
. In startup.m
, enter:
if (exist([matlabroot filesep 'last_dir.mat']) == 2)
load ([matlabroot filesep 'last_dir'])
cd(last_dir)
clear last_dir
end
In finish.m
, enter:
last_dir = pwd;
save([matlabroot filesep 'last_dir'], 'last_dir')
MATLAB will now start where you left it at the end of the last session. Note this won't work if MATLAB stopped unexpectedly (i.e., crashed).
Upvotes: 2
Reputation: 1927
You can create (or modify) a startup script in your MATLAB root directory (or anywhere on your MATLAB search path) with the exact name of startup.m
. All you write in this script will execute each time MATLAB is started. There you can change current folder using cd
:
cd('the_starting_root_you_prefer')
And save it. If you want to know your root directory, use matlabroot
.
Upvotes: 2