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:23:02 +0000 (UTC)
Organization: Ricardo UK Ltd
Lines: 30
Message-ID: <gata66$d30$1@fred.mathworks.com>
References: <gat6nh$c36$1@fred.mathworks.com>
Reply-To: "Steve Amphlett" <Firstname.Lastname@Where-I-Work.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1221733382 13408 172.30.248.37 (18 Sep 2008 10:23:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 18 Sep 2008 10:23:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 43398
Xref: news.mathworks.com comp.soft-sys.matlab:490746


"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