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: Wed, 7 Jul 2010 20:57:41 +0200

On Wed, Jul 7, 2010 at 7:15 PM, Judd Storrs <address@hidden> wrote:
>> octave1:>count = zeros(1,20);
>> octave2:>for i = 1:length(data)
>> octave3:>    count(data(i, 3))++;
>> octave4:>endfor
>
> count = histc(data(:,3),1:20)
>

or more directly (histc uses lookup & accumarray under the hood for
more than 3 bins)

count = accumarray (data(:,3), 1, [1, 20]);

accumarray can handle a lot, it's good to know about it :)

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