Prev: mean block in simulink
Next: Newbie Newey-West
From: Jan Simon on 26 Mar 2010 15:25 Dear Matt J! > function C=path2cell(pathstr) > p=pathstr(:).'; > seps=find([pathsep p pathsep]==pathsep); > blklens=diff(seps)-1; > p(pathstr==pathsep)=''; > blklens=nonzeros(blklens); > C=mat2cell(p,1,blklens); > C=C(:); To get all M-files in the path, GENPATH might be not sufficient: a subfolder could be excluded. Why not using just PATH directly and let Matlab split it to a cell: C = dataread('string', path, '%s', 'delimiter', pathsep); And then descend in each of the folders and use WHAT or DIR to find your files. Consider this: .m, .p, .mdl, ['.', mexext], \private subfolders, subfolders for objects (e.g. @cell) --- more ideas? Kind regards, Jan
From: Matt J on 26 Mar 2010 15:54 "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hoj1n1$mhe$1(a)fred.mathworks.com>... > To get all M-files in the path, GENPATH might be not sufficient: a subfolder could be excluded. Why not using just PATH directly and let Matlab split it to a cell: > C = dataread('string', path, '%s', 'delimiter', pathsep); > And then descend in each of the folders and use WHAT or DIR to find your files. > Consider this: .m, .p, .mdl, ['.', mexext], \private subfolders, subfolders for objects (e.g. @cell) --- more ideas? ====== In general, that's probably what you'd have to do, Jan. I'm a little unsure of how to interpret the OP, which seems to ask for files on a "path". That would exclude @-directories and private/ directories... Interesting about dataread(), though. It's not documented...
From: us on 26 Mar 2010 16:02 "Matt J " > > C = dataread('string', path, '%s', 'delimiter', pathsep); > Interesting about dataread(), though. It's not documented... well... from type strread; % we learn: % strread(...) <==> dataread('string',...) % so, C=strread(path, '%s', 'delimiter', pathsep); :-) us
From: Jan Simon on 26 Mar 2010 16:24 Dear Matt J! > > C = dataread('string', path, '%s', 'delimiter', pathsep); > Interesting about dataread(), though. It's not documented... You can call the documented STRREAD. But this adds a buffer size to the call of the MEX DATAREAD only and wastes a remarkable chunk of time with using VARARGIN/VARGARGOUT. If you call DATAREAD('file', ...) the benefit i much larger: TEXTREAD starts with a call to: EXIST(FileName) ~= 2 Calling EXIST without specifying the type will start a time-consuming search for files in the complete path considering M-, Mex, -MDL, P-files, variables, classes, directories, Java class and built-in function. Horrible! So you can save time by calling DATAREAD('file', FileName, ...) directly with a FileName containing the absolute path. Except for the BUFFERSIZE, DataRead is compatible since Matlab at least 6.5 (in 5.3 TEXTREAD itself was a MEX), but undocumented. Kind regards, Jan
From: forkandwait w on 26 Mar 2010 16:27
> - simply looking for all M-files within a folder and its subfolder(s)... Yes. > - looking for dependecies of a (main-) function... No. |