Why can't I save my MATLAB path on Windows?
Show older comments
I use MATLAB on a Windows computer. When I try to execute the function 'savepath' in MATLAB, my path is not saved and I receive the following warning:
>> savepath
Warning: Unable to save path to file 'C:\Program Files\MATLAB\R2023a\toolbox\local\pathdef.m'.
You can save your path to a different location by calling SAVEPATH with an input argument that specifies the full path.
For MATLAB to use that path in future sessions, save the path to 'pathdef.m' in your MATLAB startup folder.
When I try to save the MATLAB path from the 'Set Path' dialog, I get the message:
MATLAB cannot save changes to the path.
The path file, pathdef.m, might be read-only or might be in a directory for which you do not have write access.
You can save pathdef.m to a different location. In order for MATLAB to use that pathdef.m
in future sessions, you need to save it in your MATLAB startup directory (the directory from which you start MATLAB).
Would you like to save pathdef.m to another location?
Accepted Answer
More Answers (1)
yunhui zhou
on 19 Mar 2020
Edited: yunhui zhou
on 19 Mar 2020
2 votes
Please note the following words in error message: " You can save pathdef.m to a different location, In order for MATLAB to user the pathdef.m in future sessions, you need to save it in your MATLAB startup directory (the directory from which you start MATLAB). Would you like to save pathdef.m to another location?".
Just copy and save pathdef.m to your user directory (for example "C:\Users\<Your_Name>\Documents\MATLAB") and you can save your path without messing the MATLAB path for other users of your computer.
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
