From: Darlis on 15 Jan 2010 00:57 Dear all Do you know the matlab builtin function to get a count for each group for example : data = [ 2; 4; 1; 2; 1; 3; 1; 2; 2; 1; 5; 4;] the result I hope to obtain : 1 4 2 4 3 1 4 2 5 1 Thank you very much; Dalris
From: Darlis on 15 Jan 2010 01:31 I have tried to use the classic (iterative) way. I look for the fastest way, maybe there is a matlab builtin function for i=1:max(data) grp(i,1)=i; grp(i,2)=size(find(data==i),1); end; Regards Darlis "Darlis " <darlis(a)cs.its.ac.id> wrote in message <hip03e$57v$1(a)fred.mathworks.com>... > Dear all > > Do you know the matlab builtin function to get a count for each group > for example : > data = [ > 2; > 4; > 1; > 2; > 1; > 3; > 1; > 2; > 2; > 1; > 5; > 4;] > > the result I hope to obtain : > 1 4 > 2 4 > 3 1 > 4 2 > 5 1 > > Thank you very much; > > Dalris
From: Pekka Kumpulainen on 15 Jan 2010 02:08 "Darlis " <darlis(a)cs.its.ac.id> wrote in message <hip03e$57v$1(a)fred.mathworks.com>... > Dear all > > Do you know the matlab builtin function to get a count for each group > for example : > data = [ > 2; > 4; > 1; > 2; > 1; > 3; > 1; > 2; > 2; > 1; > 5; > 4;] > > the result I hope to obtain : > 1 4 > 2 4 > 3 1 > 4 2 > 5 1 > > Thank you very much; > > Dalris One opition is to use howmany from FEX: http://www.mathworks.com/matlabcentral/fileexchange/?term=howmany [a,b] = howmany(data) >> [a b] ans = 1 4 2 4 3 1 4 2 5 1
From: us on 15 Jan 2010 02:50 "Darlis " <darlis(a)cs.its.ac.id> wrote in message <hip03e$57v$1(a)fred.mathworks.com>... > Dear all > > Do you know the matlab builtin function to get a count for each group > for example : > data = [ > 2; > 4; > 1; > 2; > 1; > 3; > 1; > 2; > 2; > 1; > 5; > 4;] > > the result I hope to obtain : > 1 4 > 2 4 > 3 1 > 4 2 > 5 1 > > Thank you very much; > > Dalris one of the many solutions [du,dx,dx]=unique(data); dx=accumarray(dx,1); r=[du,dx] %{ % r = 1 4 2 4 3 1 4 2 5 1 %} us
From: ImageAnalyst on 15 Jan 2010 06:24 Another alternative is to use the hist, histc, or imhist function.
|
Pages: 1 Prev: Rayleigh Fading Next: Please help: Error- "Colon operands must be in range of the data type" |