フィルターのクリア

Doesn't addpath support adding multiple folder paths at the same time?

25 ビュー (過去 30 日間)
cui,xingxing
cui,xingxing 2022 年 2 月 28 日
編集済み: Max Heimann 2022 年 2 月 28 日
For example, I have 2 paths of the same level of brothers, how can I add them to the matlab search path by command addpath?
path1 = "parentFolder1/";
path2 = "parentFolder2/";
addpath([path1,path2])
Error using catdirs (line 25)
All arguments must be character vectors.

Error in addpath (line 64)
p = catdirs(mfilename, varargin{1:n});

Error in addpath (line 49)
warnings = evalc('native_addpath(varargin{:})');
Is the solution to use addpath 2 times, when there are more sibling folders, it seems inelegant to call addpath multiple times?
addpath(path1);
addpath(path2);
addpath(...)
...

採用された回答

Max Heimann
Max Heimann 2022 年 2 月 28 日
編集済み: Max Heimann 2022 年 2 月 28 日
According to the addpath documentation (mathworks.com/help/matlab/ref/addpath.html), you can add multiple paths at the same time by passing them as comma separated inputs.
If you want to add a dynamically sized list of paths with one call you could add the paths to a cell of strings
paths = {'path1','path2', .. ,'pathN'}
And then call addpath with all entries of paths
addpath(paths{:})

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by