|
Re: matlab version and "for" loops
Posted:
Jan 21, 2013 6:53 PM
|
|
"Jessica" wrote in message <kdki7n$b6g$1@newscl01ah.mathworks.com>... > "Jan Simon" wrote in message <kdj1jg$i5i$1@newscl01ah.mathworks.com>... > > 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.
Bruno
|
|