Path: news.mathworks.com!not-for-mail
From: "Steve Amphlett" <Firstname.Lastname@Where-I-Work.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Wavread loop: Variable filename
Date: Thu, 18 Sep 2008 10:29:03 +0000 (UTC)
Organization: Ricardo UK Ltd
Lines: 37
Message-ID: <gatahf$fsi$1@fred.mathworks.com>
References: <gat6nh$c36$1@fred.mathworks.com> <gata66$d30$1@fred.mathworks.com>
Reply-To: "Steve Amphlett" <Firstname.Lastname@Where-I-Work.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1221733743 16274 172.30.248.38 (18 Sep 2008 10:29:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 18 Sep 2008 10:29:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 43398
Xref: news.mathworks.com comp.soft-sys.matlab:490749


"Steve Amphlett" <Firstname.Lastname@Where-I-Work.com> wrote in message <gata66$d30$1@fred.mathworks.com>...
> "Koos Spee" <bmx_360@hotmail.com> wrote in message <gat6nh$c36$1@fred.mathworks.com>...
> > Hello,
> > 
> > I have a set of (wav)files e.g.
> > 
> > file01.wav, file02.wav, file03.wav etc.
> > 
> > Now, I want to get load these files into Matlab with a loop and storing them into load01, load02, load03 etc
> > 
> > However I am not able to give them the correct filename. I tried for example:
> > 
> > for i=1:3
> >     StrI=int2str(i);
> >     WavName='file';
> >     WavStored='load';
> >     temp=strcat(WavName, StrI);
> >     strcat(WavStored, StrI)=wavread(temp);
> > end
> > 
> > Also looked into dir('*wav'), but that leads to the same problem
> 
> What about something different like this (untested):
> 
> files=dir('*.wav');
> for file = files
>   file.data=wavread(file.name);
> end

Should have tested!

files=dir('*.wav');
  for n=1:length(files);
  files(n).data=wavread(files(n).name);
end