Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

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

Posts: 19
Registered: 12/7/04
Re: Code Optimisation
Posted: Feb 14, 2005 5:48 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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;




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.