Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
dpb
Posts:
6,847
Registered:
6/7/07
|
|
Re: Listing Files With Certain Names
Posted:
Mar 5, 2013 9:07 AM
|
|
On 3/5/2013 7:40 AM, S Stron wrote: > Hi all, > I'm attempting to load files into the MATLAB workspace that have > specific beginnings and endings but the same middle as other files. > i.e. I'd like to load 'cf_file_1.mat', 'cf_file_2.mat', but not > 'jd_file_1.mat'. > > At the moment my code looks like this, which works but I need to define > a 'files' variable as the number fo files found. However I can't get the > eval function to output the particular files under a variable name. > > ppt=input('ppt initials?', 's'); eval(['dir ' ppt '_file_*.mat;']); > > So really, how can I call x number of files with specific names whilst > counting the amount of them? ...
Forget eval; use dir()...
d=dir([ppt '_file_*.mat;']); for f={d.name} s=load(f); % say, if SAVEd... end
doc dir
--
|
|
|
|