Desktop Tools and Development Environment Previous page   Next Page

Saving Settings to the Path

When you make changes to the search path, they remain in effect during the current MATLAB session. To keep the changes in effect for subsequent sessions, you need to save them. To save changes using the Set Path dialog box, click Save.

If you want to automatically use this search path in future sessions, save the path to your MATLAB startup directory, which saves pathdef.m to that location. You can save the changes to the default pathdef.m file, in $matlabroot/toolbox/local if you have write permission for that directory but see the following caution. Alternatively, you can include addpath and rmpath statements in a startup.m file, which avoids some problems you might have with saving the path, for example, using the same path with both Windows and UNIX platforms. For more information, see Using the Path in Future Sessions.

Caution Against Saving Files in $matlabroot/toolbox.   Save any M-files you create and any MathWorks supplied M-files that you edit in a directory that is not in the $matlabroot/toolbox directory tree. If you keep your files in $matlabroot/toolbox directories, they can be overwritten when you install a new version of MATLAB. Also note that locations of files in the $matlabroot/toolbox directory tree are loaded and cached in memory at the beginning of each MATLAB session to improve performance. If you save files to $matlabroot/toolbox directories using an external editor or add or remove in from these directories using file system operations, run rehash toolbox before you use the files in the current session. If you make changes to existing files in $matlabroot/toolbox directories using an external editor, run clear functionname before you use the files in the current session. For more information, see rehash or Toolbox Path Caching in MATLAB.

Function Alternative.   Use savepath to save the current path to pathdef.m. Locate pathdef.m in your MATLAB startup directory to automatically use it in future sessions. Consider using savepath in your finish.m file. To modify the default path upon startup, include addpath and rmpath functions in your startup.m file. For more information, see Modifying the Path in a startup.m File.


Previous page  Restoring the Default Search Path Using the Path in Future Sessions Next page

© 1994-2005 The MathWorks, Inc.