help-octave
[Top][All Lists]
Advanced

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

Re: Vectorisation


From: Jaroslav Hajek
Subject: Re: Vectorisation
Date: Fri, 23 Jul 2010 10:16:10 +0200

On Fri, Jul 23, 2010 at 10:04 AM, gastonjulia
<address@hidden> wrote:
>
> Thanks Jaroslav,
>
> but I don't think that this is what I want to do. Let try to explain my
> problem with a piece of linear code.
>
> 1>data = load('results.vec'); % Btw, is there way to increase speed here?
> 2>for i = 1:length(data) % length(data) is appr. 2e6
> 3>    if (data(i,6) == 14)
> 4>        count(data(i,2)+1)++;
> 5>    endif
> 6>endfor
>
> The problem with the for loop is solved by `count =
> accumarray(data(:,2)+1,1)', I can see that, but I don't see where to fit in
> the condition.
>

As far as I see, that should be exactly it. If you have data where the
loop (provided count is zero-initialized) gives a different result
than my expression above, I'd love to see them.

best regards

-- 
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]