The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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  

Posts: 9,850
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={}
s=load(f); % say, if SAVEd...

doc dir


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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.