Another pathdef.m question

10 views (last 30 days)
Stan Kruger
Stan Kruger on 6 Feb 2015
Commented: Stan Kruger on 9 Feb 2015
I've seen this question asked multiple times, and have still not found a satisfactory answer.
I am running matlab from unix, and I do not have write permissions in the folder where matlab is kept. I want matlab to read and apply my custom path definitions as written in pathdef.m - I want this done automatically on startup. If I start matlab from my own data allocation, within the folder where I keep pathdef.m, there is no problem, matlab reads pathdef.m and all my paths are defined as I want. However, if I start matlab from anywhere else, matlab doesn't read pathdef.m, and I have to manually set the path. This is undesireable, I want pathdef.m to be read and applied no matter where I start matlab from.
I assume this same problem will occur if I customize a startup.m file as well, which is also undesireable. Can anybody assist me? Thanks.

Answers (1)

Jan
Jan on 7 Feb 2015
The pathdef.m included in Matlab's program path matlabroot is used, if there is no such file in the current directory, as you have observered. This is the wanted behavior, because the path should be defined properly as default.
In opposite to pathdef.m there is no startup.m file included in Matlab as default. Therefore the startup function is user-defined only. Therefore the startup function is the right location to include user-defined changes to the path.
  1 Comment
Stan Kruger
Stan Kruger on 9 Feb 2015
Hi Jan, thanks for the answer. I do agree that it is important to have a well defined default path, however, it seems even more important to be able to control what that default path is. It sounds like you are saying that this is not an option in my case. Since I lack the permissions to change this default pathdef.m the only real option is to make sure I always start matlab from the directory where I have created my own pathdef.m.
Is this accurate? Thanks very much.

Sign in to comment.

Categories

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

Community Treasure Hunt

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

Start Hunting!