Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Select value from loop
Date: Wed, 25 Feb 2009 04:26:03 +0000 (UTC)
Organization: University of Memphis
Lines: 39
Message-ID: <go2h8r$t05$1@fred.mathworks.com>
References: <go2e1n$6lq$1@fred.mathworks.com> <go2eq4$r8p$1@fred.mathworks.com> <go2gk9$c0o$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1235535963 29701 172.30.248.37 (25 Feb 2009 04:26:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 25 Feb 2009 04:26:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 233092
Xref: news.mathworks.com comp.soft-sys.matlab:520608

"Godzilla " <godzilla@tokyo.edu> wrote in message <go2gk9$c0o$1@fred.mathworks.com>...
> "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <go2eq4$r8p$1@fred.mathworks.com>...
> > "Sylvie " <sylpel@yorku.ca> wrote in message <go2e1n$6lq$1@fred.mathworks.com>...
> > > Hello there,
> > > 
> > > I set up a for loop to read 480 different image files. I would like to select every third images.
> > > 
> > > Image 1 (select)
> > > Image2 (Dont select)
> > > Image3(Dont select)
> > > Image4(Select)
> > > Image5 (Dont select)
> > > Image6(Dont select)
> > > Image7(select)
> > > etc...
> > > 
> > > I am not sure which command I should use 
> > > 
> > > Thanks
> > > 
> > > Sylvie
> > 
> >    If your for-loop has an index that goes from 1 to 480, you can write:
> > 
> >  for k = 1:480
> >   if mod(k,3)==1
> >    % then "select"
> >  end
> > end
> > 
> > Roger Stafford
> 
> if ~mod(k,3)
>    % then "select"
>  end
> 
> might be faster. 

My guess was wrong.  The 'mod(k,3)==1' version seems a bit faster but hardly worth mentioning.