savepath - Save current search path - MATLAB (original) (raw)
Main Content
Syntax
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.
In MATLAB Online™, changes to the path are automatically saved. Therefore, callingsavepath
is not necessary.
savepath [folderName](#buofh7k-1-folderName)/pathdef.m
saves the current search path to pathdef.m
located in the folder specified by folderName
. If you do not specifyfolderName
, then savepath
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. The status
output is 0
when savepath
is successful, and 1
otherwise.
Examples
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
folderName
— Folder name
string array | character vector
Folder name, specified as a string array or character vector. folderName
can be a relative or absolute path.
Example: C:\myFolder
Tips
- To display the paths to all
pathdef.m
files in the current folder and on the current search path, usewhich
.
Thesavepath
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.
Version History
Introduced before R2006a