Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Listing Files With Certain Names
Replies: 1   Last Post: Mar 5, 2013 9:07 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
dpb

Posts: 8,289
Registered: 6/7/07
Re: Listing Files With Certain Names
Posted: Mar 5, 2013 9:07 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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

--




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.