Why is my modified path not saved in MATLAB when I only have one pathdef.m?

1 view (last 30 days)
When I use "which pathdef -all" it is confirmed it is only defined once. It is in the default directory (C:\Program Files (x86)\MATLAB\R2015b\toolbox\local\pathdef.m) and has the MatLab installation date. If I look at this file post savepath and MatLab exit it has not been updated. This is with R2015b (recently installed after use of R2012b).

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 23 Jan 2018
Ruan flag=savepath to see if there is any file access issue.
savepath returns:
0 if the file was saved successfully
1 if the file could not be saved

More Answers (5)

Ian Roberts
Ian Roberts on 23 Jan 2018
Thanks - it returned a 1 so I need to get my permissions updated to get write access to the directory.

Walter Roberson
Walter Roberson on 23 Jan 2018
You probably do not have write access to that location. MS Windows does not permit users to write into C:\Program Files (x86)
You should save into a different location. Or you should Run As Administrator to gain permission to write in the existing location.

Ian Roberts
Ian Roberts on 23 Jan 2018
Thanks. I'll try via the IT department first as there also printing issues with java, otherwise I'll have to move it to a separate directory.

Jan
Jan on 23 Jan 2018
The files inside C:\Program Files (x86)\MATLAB\R2015b\ required admin privileges for writing. If you want to modify matlabroot\toolbox\local\pathdef.m, start Matlab with admin privileges, or modify the file permissions of the \toolbox\local folder, if you plan to modify pathdef.m frequently.

Rui Guerra
Rui Guerra on 10 May 2019
I had the same problem in ubuntu and the simple workaround is the following (you must be able to run as superuser):
  1. On the terminal run $ sudo nautilus. This will allow you to open the folders as superuser.
  2. Navigate to /usr/local/MATLAB/R2019a/toolbox/local (in this example the version is R2019a)
  3. Click on pathdef.m with the mouse right button and choose "Properties"
  4. On the window that will open choose the tab "Permissions"
  5. Change the permissions from "Read only" to "Read and write"
  6. Close the window and that's it. You can now set the path permanently in matlab.
  7. If you feel unconfortable by having that file in the status "read and write", repeat the steps and make it again "read only". But in principle there is nothing wrong in let it be that way if you are the only user of your computer.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!