genpath related question, replacing genpath
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have two questions regarding genpath:
(1) When I use genpath as follows:
p = genpath('/Users/myname')
I get the following:
/Users/myname/:/Users/myname/.Trash:/Users/myname/.Trash/Recovered files:/Users/myname/.Trash/Recovered files #1:/Users/myname ...
..what is that even supposed to mean? why am I not getting a string of the subfolders?
(2) In the following: addpath(genpath('/Users/myname')) I want to replace the genpath (it does not work propertly with a certain program). How can I do that?
Thanks
0 Kommentare
Antworten (1)
Geoff Hayes
am 5 Jun. 2014
According to the documentation on genpath (type help genpath or doc genpath in the Command Window for details)
P = genpath(D) returns a path string starting in D, plus, recursively,
all the subdirectories of D, including empty subdirectories.
So your above result, /Users/myname/:/Users/myname/.Trash:/Users/myname/.Trash/Rec…, includes the path string starting in /Users/myname/, and all subdirectories of * /Users/myname/ with each subdirectory separated by a colon.
As for addpath, in the Command Window type help add path or doc add path for details. It includes several examples
Examples
addpath c:\matlab\work
addpath /home/user/matlab
addpath /home/user/matlab:/home/user/matlab/test:
addpath /home/user/matlab /home/user/matlab/test
I tried addpath(genpath('/Users/geoff/Dev/test')) and it worked fine, adding this directory and all subdirectories as expected. If you are finding that your statement addpath(genpath('/Users/myname')) does not work, then simply edit out the directories from genpath that are invalid:
pathString =genpath('/Users/myname');
% do your edits on pathString
addpath(pathStringEdited);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Search Path finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!