Documentation

savepath

Save current search path

Syntax

  • savepath
  • savepath folderName/pathdef.m example
  • status = savepath(___)

Description

savepath saves the current MATLAB® search path to an existing pathdef.m file in the current folder. If there is no pathdef.m file in the current folder, then savepath saves the search path to the first pathdef.m file on the current path. If there is no such file on the current path, then savepath saves the search path to the pathdef.m file that MATLAB located at startup.

On a Windows® system with User Account Control (UAC) enabled, you might be prompted to allow the update operation because it requires administrator-level permission.

example

savepath folderName/pathdef.m saves the current search path to pathdef.m located in the folder specified by folderName. If you do not specify folderName, then savepath saves pathdef.m in the current folder.

Use this syntax if you do not have write access to the current pathdef.m file.

status = savepath(___) additionally indicates if the operation is successful, using any of the input arguments in the previous syntaxes. The status output is 0 when savepath is successful, and 1 otherwise.

Examples

collapse all

Save Search Path to Specific Folder

Save the current search path to pathdef.m located in the folder, I:/my_matlab_files.

savepath I:/my_matlab_files/pathdef.m

Input Arguments

collapse all

folderName — Folder namestring

Folder name, specified as a string. folderName can be a relative or absolute path.

Example: C:\myFolder

More About

collapse all

Tips

  • To display the paths to all pathdef.m files in the current folder and on the current search path, use which.

    which pathdef.m -all
    The savepath command updates the first pathdef.m file in this list.

  • To save the search path programmatically each time you exit MATLAB, use savepath in a finish.m file.

  • To save a search path and automatically use it in a future session, use the savepath folderName/pathdef.m syntax and set the folder specified by folderName as the MATLAB startup folder.

See Also

| | | |

Introduced before R2006a

Was this topic helpful?