Documentation

savepath

Save current search path

Syntax

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

Description

savepathsaves the current MATLAB®search path to an existingpathdef.mfile in the current folder. If there is nopathdef.mfile in the current folder, thensavepathsaves the search path to the firstpathdef.mfile on the current path. If there is no such file on the current path, thensavepathsaves the search path to thepathdef.mfile 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

savepathfolderName/pathdef.msaves the current search path topathdef.mlocated in the folder specified byfolderName. If you do not specifyfolderName, thensavepathsavespathdef.min the current folder.

Use this syntax if you do not have write access to the currentpathdef.mfile.

status = savepath(___)additionally indicates if the operation is successful, using any of the input arguments in the previous syntaxes. Thestatusoutput is0whensavepathis successful, and1otherwise.

Examples

collapse all

Save the current search path topathdef.mlocated in the folder,I:/my_matlab_files.

savepathI:/my_matlab_files/pathdef.m

Input Arguments

collapse all

Folder name, specified as a string array or character vector.folderNamecan be a relative or absolute path.

Example:C:\myFolder

Tips

  • To display the paths to allpathdef.mfiles in the current folder and on the current search path, usewhich.

    whichpathdef.m-all
    Thesavepathcommand updates the firstpathdef.mfile in this list.

  • To save the search path programmatically each time you exit MATLAB, usesavepathin afinish.mfile.

  • To save a search path and automatically use it in a future session, use thesavepathfolderName/pathdef.msyntax and set the folder specified byfolderNameas the MATLAB startup folder.

Introduced before R2006a

Was this topic helpful?