From: Ben on
Hi

I have been looking for a function that will return the say 3 most common values in a
1-d matrix, I havnt been able to find one that works for me and was just wondering if anyone can point me in the right direction if there is one already uploaded.

Thanks
From: TideMan on
On May 11, 4:02 pm, "Ben " <ben.pink...(a)gmail.com> wrote:
> Hi
>
> I have been looking for a function that will return the say 3 most common values in a  
> 1-d matrix, I havnt been able to find one that works for me and was just wondering if anyone can point me in the right direction if there is one already uploaded.
>
> Thanks

Saying a 1-D matrix is like saying a couple of one.
A matrix is a 2-D array.
A 1-D array is a vector.

To answer your question:
help hist
From: Bruno Luong on
"Ben " <ben.pinkham(a)gmail.com> wrote in message <hsakse$97e$1(a)fred.mathworks.com>...
> Hi
>
> I have been looking for a function that will return the say 3 most common values in a
> 1-d matrix, I havnt been able to find one that works for me and was just wondering if anyone can point me in the right direction if there is one already uploaded.
>

>> A=[1 2 5 4 9 5 8 5 4 3 3 0 2]

A =

1 2 5 4 9 5 8 5 4 3 3 0 2

>> [C I] = sort(histc(A,U),'descend')

C =

3 2 2 2 1 1 1 0 0 0


I =

5 2 3 4 1 8 9 6 7 10

>> M = U(I(1:3))

ans =

5 2 3

% Bruno
From: Ben on
thanks guys thats what i've been looking for
 | 
Pages: 1
Prev: GUI and simulink
Next: Laguerre Function