|On this page…|
The startup.m file is for specifying startup options. You can add folders to the search path by including addpath statements in startup.m. For example, to add the specified folders, /home/username/mytools to the search path, include this statement:
For more information, see Startup Options.
On UNIX® and Macintosh platforms, you can define a secondary userpath by setting the MATLABPATH environment variable. By default, MATLAB® adds userpath to the search path upon startup.
This example shows how to add two folders, /home/j/Documents/MATLAB/mine and /home/j/Documents/MATLAB/mine/research, to the search path upon startup on a UNIX platform. The procedure is similar for Macintosh platforms.
Assume userpath is set to the default value on a UNIX platform with a csh shell, where j is your home folder. That is, the primary userpath is /home/j/Documents/MATLAB. In a terminal, set the MATLABPATH environment variable. Separate multiple folders using a colon (:):
setenv MATLABPATH '/home/j/Documents/MATLAB/mine':'/home/j/Documents/MATLAB/mine/research'
MATLABPATH home/j/Documents/MATLAB home/j/Documents/MATLAB/mine home/j/Documents/MATLAB/mine/research home/j/Applications/MATLAB/R2009a/toolbox/matlab/general home/j/Applications/MATLAB/R2009a/toolbox/matlab/ops ...
The two folders, /home/j/Documents/MATLAB/mine and /home/j/Documents/MATLAB/mine/research, are set as the secondary userpath. They are both added to the search path upon startup, as long as the shell runs. To set the secondary userpath for all future MATLAB sessions, set the MATLABPATH environment variable in your startup script.