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: matlab version and "for" loops
Replies: 15   Last Post: Feb 13, 2013 4:53 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bruno Luong

Posts: 9,822
Registered: 7/26/08
Re: matlab version and "for" loops
Posted: Jan 21, 2013 6:53 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Jessica" wrote in message <kdki7n$b6g$>...
> "Jan Simon" wrote in message <kdj1jg$i5i$>...
> > Dear Jessica,
> >
> > Yes, "newer" versions of Matlab interpret loops much faster using the JIT acceleration. Please note that this means "newer" than version 6.1 from June 2001.
> >
> > To check the difference type:
> >
> > feature('accel', 'off')
> > feature('jit', 'off')
> >
> > and run your program again.
> >
> > If you want to accelerate your code, post it here to get our ideas.
> >
> > Kind regards, Jan

> Thanks for this information. My problem is in running this code:
> %Delete saccades except when they mark the start/stop of image
> DataLength=size(Sdata);DataLength=DataLength(1);
> for i=0:DataLength-1
> if strcmp(GazeType(DataLength-i,1),'Saccade')==1|strcmp(GazeType(DataLength- i,1),'Unclassified')==1;
> if strcmp(PictureStartColumn2(DataLength-i),'ImageStart')==0
> if strcmp(PictureStartColumn2(DataLength-i),'ImageEnd')==0;
> Stextdata2(DataLength-i,:)=[];
> Sdata(DataLength-i,:)=[];
> end;
> end;
> end;
> end;
> end;

First, it's not for-loop that is slow. Thing that is slow is calling strcmp many times.
strcmp can work on cell of strings. You should use strcmp and logical indexing to remove unwanted data. No need for-loop at all.


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.