savepath
Save current search path
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.
InMATLAB Online™, changes to the path are automatically saved. Therefore, callingsavepath
is not necessary.
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.
To automatically use the saved search path in a future session, specifyfolderName
as the MATLAB startup folder.
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.