help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: blocking nested cycles


From: Jaroslav Hajek
Subject: Re: blocking nested cycles
Date: Tue, 29 Jun 2010 12:47:36 +0200

On Tue, Jun 29, 2010 at 11:38 AM, octave_user <address@hidden> wrote:
>
> Hi!
> I created a function in Matlab, which has a problem. The code is the
> following:
>
> ==============
> for i=1:m
>  for j=1:n
>  for jj=1:m
>   if x(j)<tresholdX(jj) & y(j)<tresholdY(jj)
>        ET=[ET; i j];
>        break
>    end
>   end
>  end
> end

You can use an extra control variable tested in the outer loops, or
make this a function and use return.
Of course, an even much better idea is to get rid of the loops
completely and use array masks and find instead.

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

[Prev in Thread] Current Thread [Next in Thread]