Doesn't addpath support adding multiple folder paths at the same time?
27 次查看(过去 30 天)
显示 更早的评论
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])
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(...)
...
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 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!