savepath
Save current search path
Syntax
savepath
savepath folderName/pathdef.m
status = savepath(___)
Description
savepath
saves the current MATLAB®search path to an existingpathdef.m
file in the current folder. If there is nopathdef.m
file in the current folder, thensavepath
saves the search path to the firstpathdef.m
file on the current path. If there is no such file on the current path, thensavepath
saves the search path to thepathdef.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.
savepath
saves the current search path tofolderName
/pathdef.mpathdef.m
located in the folder specified byfolderName
. If you do not specifyfolderName
, thensavepath
savespathdef.m
in the current folder.
Use this syntax if you do not have write access to the currentpathdef.m
file.
status = savepath(___)
additionally indicates if the operation is successful, using any of the input arguments in the previous syntaxes. Thestatus
output is0
whensavepath
is successful, and1
otherwise.
Examples
Input Arguments
Tips
To display the paths to all
pathdef.m
files in the current folder and on the current search path, usewhich
.whichpathdef.m-all
savepath
command updates the firstpathdef.m
file in this list.To save the search path programmatically each time you exit MATLAB, use
savepath
in afinish.m
file.To save a search path and automatically use it in a future session, use the
savepath
syntax and set the folder specified byfolderName
/pathdef.mfolderName
as the MATLAB startup folder.