Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Code Optimisation
Replies: 11   Last Post: Feb 22, 2005 12:02 PM

 Messages: [ Previous | Next ]
 mehrnoush Posts: 19 Registered: 12/7/04
Re: Code Optimisation
Posted: Feb 14, 2005 5:48 PM

try this:

ind=Frame1(:,:,1)>=0 && Frame1(:,:,1)<=0.09 && ...(rest of your
conditi0ns);
Frame1(ind,1) = 0.07;
Frame1(ind,2) = 1.00;
Frame1(ind,3) = 0.48;
Frame1(~ind,:) = 0;

Dave Barry wrote:
>
>
> Does anyone have any ideas on how to optimise the following piece
> of
> code so that it finishes faster. Thanks for your help.
>
> for n = 1:120;
> for m = 1:160;
> if (((Frame1(n,m,1) >= 0.00)&&(Frame1(n,m,1) <=
> 0.09))&&((Frame1(n,m,2) >= 0.77)&&(Frame1(n,m,2) <=
> 1.00))&&((Frame1(n,m,3) >= 0.19)&&(Frame1(n,m,3) <= 0.48)));
> Frame1(n,m,1) = 0.07;

> else
> Frame1(n,m,1) = 0;
> Frame1(n,m,2) = 0;
> Frame1(n,m,3) = 0;
> end;
> end;
> end;

Date Subject Author
2/14/05 Dave Barry
2/14/05 mehrnoush
2/14/05 Randy Poe
2/14/05 Guillermo
2/15/05 Steven Lord
2/14/05 Guillermo
2/14/05 Guillermo
2/14/05 Randy Poe
2/14/05 Guillermo
2/14/05 per isakson
2/14/05 Guillermo
2/22/05 Dave Barry