MATLAB: How to have a vector that counts how many repetitive numbers there is in another vector

counting numbershistogramvector

So i have a vector with 100 numbers. And those numbers only goes until 51.
For example A = [ 50 49 32 21 50 38 41 2 46…..]
And what i want is a vector B that has 51 numbers and tells me for example how many 1's there is in vector A, and how many 2's there's in the vector and so on.
Thank you

Best Answer

Maybe try this example:
A = [1 2 3 3 4 5 1]
u = unique(A)
Expected_result = histc(A,u)