How to permanently set the search path?
21 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone! I am using Matlab R2018a and am unable to permanently set the search path using the Set Path option or the savepath() function. Could you please help?
2 件のコメント
Shivaputra Narke
2018 年 10 月 19 日
Did you check pathdef.m file ? which pathdef.m and which pathdef.m -all
採用された回答
Image Analyst
2018 年 10 月 19 日
Have you tried doing Set Path on the tool ribbon (Home tab) and then selecting a folder and saving it? Otherwise, you can create a startup.m file and put it there.
>> edit startup.m
Then add a line
addpath(genpath('D:/Matlab/Work/Utilities'));
using whatever folder you want. You can also cd to a desired starting folder in the startup.m if you want. Just add the line
cd('d:/MATLAB/work/MyFirstProject');
using whatever folder you want to start in. I'm pretty sure the startup.m file will be in a folder that you have read and write permission for. If not, let us know what userpath is
>> userpath
0 件のコメント
その他の回答 (3 件)
Walter Roberson
2018 年 10 月 19 日
編集済み: Walter Roberson
2018 年 10 月 19 日
It is not possible to do permanently (as in, not possible to change.) The system administrator can always remove the file that is used to hold the path information.
If you are having a difficulty where your changes to the path are not "sticking" between sessions, then it is possible that you might not have write access to the default location.
There are several different work-arounds possible for that. The easiest is to run MATLAB as administrator so it has write access. Another way is to savepath() to a file in your current directory. A third way is to savepath() to the location indicated by userpath() and if necessary put a startup.m there that executes that pathdef . A fourth way is to change the MATLABPATH environment variable to point to a file containing the pathdef .
1 件のコメント
John D'Errico
2018 年 10 月 19 日
編集済み: John D'Errico
2018 年 10 月 19 日
Once your search path has been established, using tools like pathdef, addpath, rmpath, userpath, path, pathtool, you can then use savepath.
This fixes the search path, until the next time you choose to change the path. MATLAB will remember this path now.
Finally, note that your current working directory is always on top of the searchpath. So, if you CD to a new directory, what6ever pwd tells you is the current working directory. That one is on top of the path.
参考
カテゴリ
Help Center および File Exchange で Search Path についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!