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: Fri, 19 Sep 2008 12:56:02 +0000 (UTC)
Organization: Ricardo UK Ltd
Lines: 15
Message-ID: <gb07h2$pl$1@fred.mathworks.com>
References: <gat6nh$c36$1@fred.mathworks.com> <gata66$d30$1@fred.mathworks.com> <gatahf$fsi$1@fred.mathworks.com> <MPG.233d5e8a1c997d179898d1@news.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 1221828962 821 172.30.248.38 (19 Sep 2008 12:56:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 19 Sep 2008 12:56:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 43398
Xref: news.mathworks.com comp.soft-sys.matlab:490954


Loren Shure <loren@mathworks.com> wrote in message > > 
> > files=dir('*.wav');
> >   for n=1:length(files);
> >   files(n).data=wavread(files(n).name);
> > end
> > 
> > 
> > 
> 
> This is likely to cause issues as files gets redefined in a loop with a 
> control variable named files.

I understood that 1:length(files) would be expanded once and then n assigned to each column of the expansion in turn.  There are many posts here asking why modification of the "loop variable" inside the loop has no effect.

- Steve