フィルターのクリア

Search path changes to default when I run script (ubuntu)

3 ビュー (過去 30 日間)
Jasper James
Jasper James 2017 年 2 月 28 日
コメント済み: Jasper James 2017 年 3 月 6 日
I'm running R2016b on ubuntu and when I run a script the search path changes back to default. I have added a startup.m to add the desired path so it is correct when I start MATLAB.
I have also changed the initial working folder in preferences but when I restart MATLAB that reverts back to what it was. Also, I have deleted the default folder (/Docs/MATLAB) but when I start MATLAB it remakes it.
It seems that every time I make a change to any preferences at all on MATLAB they are never recorded and disappear when I restart.
Thanks for your help, Jasper
  2 件のコメント
Jan
Jan 2017 年 2 月 28 日
What exactly is your question? Perhaps you run Matlab in a virtual machine, which removes all changes after a reboot. It might be a smart idea of Matlab to recreate /Docs/MATLAB, when it is missing. What do you want to let Matlab do instead? What does "when I run a script the search path changes back to default" exactly mean? When does what change the search path and why do you assume, that anything else should happen? How do you "make a change" to the preferences and did you cross-check, that this was successful? Perhaps Matlab's preferences files require admin privileges for modifications?
Jasper James
Jasper James 2017 年 2 月 28 日
I'm not on a VM but I'll start explaining again. If I manually add a folder and its subdirectories to the path so that I can run a script it removes it from the path when I actually run it.
If I add the folder/subdirectories to a startup.m file so that initially it is on the path, once again it is removed when I run a file.
If I go in preferences and set the 'initial working file' to the one I want then it adds the folders to the path but when I run a script it again removes it.
Basically I've tried several methods to allow another directory to be added to the search path and stay on it but whenever I run a script it removes the folder I am working in from the search path.
Does this make more sense?

サインインしてコメントする。

採用された回答

Steven Lord
Steven Lord 2017 年 3 月 3 日
Have you confirmed that the script you're running doesn't call path, rmpath, restoredefaultpath, genpath, or the like either directly or by calling something else that manipulates the path? All four of those functions are MATLAB program files, so you should be able to dbstop in path, dbstop in rmpath, etc. and determine who's manipulating the path.
  1 件のコメント
Jasper James
Jasper James 2017 年 3 月 6 日
Ahh, the script was calling restoredefaultpath. Thank you so much for your help!

サインインしてコメントする。

その他の回答 (1 件)

Ruchir Kemnaik
Ruchir Kemnaik 2017 年 3 月 3 日
You can make use of the pathtool command to change the MATLAB search path.
In the case of using "startup.m" to add a path to the MATLAB search path, make sure that "startup.m" is saved in a path that exists in the MATLAB search path.
You might also want to have a look at this question.

カテゴリ

Help Center および File ExchangeSearch Path についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by