mHelpMe
mHelpMe

Reputation: 6668

setting a default matlab path at startup

My team is trying to standardise our Matlab paths so that everyone has the same.

I have a list of the default matlab path that we should all have.

So we would like to have a script that runs when matlab opens to make sure that our paths are set to the default matlab path. So if a path has been added to our default list it will be added in the correct place.

Is this possible in Matlab?

I read about startup but that seems to do with set your working directory which is different to what I am trying to do.

Upvotes: 1

Views: 1565

Answers (2)

Luis Mendo
Luis Mendo

Reputation: 112769

Include a path or addpath line in file startup.m. For example, to add folder aaa\bbb to the path the line would be

addpath('aaa\bbb')

Note that each user may have a different startup.m file. You may need to create it, if it doesn't already exist.

Upvotes: 2

rayryeng
rayryeng

Reputation: 104565

You can change which directory MATLAB starts in using the userpath function so that whenever you start up MATLAB, the path will automatically redirect here.

This may be useful if you have MATLAB running on a network per se, and multiple instances can start in the same network directory.

See more from MathWorks here: http://www.mathworks.com/help/matlab/matlab_env/matlab-startup-folder.html


However, if you want to standardize everything so that everyone has access to the same path, you can use startup to add directories / folders to MATLAB's path, but if you want to complete the package, use userpath to get MATLAB to start at a specified directory.

Your startup.m file may look something like this:

addpath('/folder/to/add/one');
addpath('/folder/to/add/two');
addpath('/folder/to/add/three');
addpath('/folder/to/add/four');

Then set your userpath with the function to complete everything:

userpath('/folder/to/start');
addpath('/folder/to/start');

Also make sure you add this new folder to your startup.m file too.

Upvotes: 2

Related Questions