Reputation: 52840
I need the counts of each element in the list. Is there some ready command for this?
>> [1 1 5 5 10 12 12 2 2 2]
ans =
1 1 5 5 10 12 12 2 2 2
Goal: getting counts like this
>> [1, 2; 5, 2; 10, 1; 12, 2]
ans =
1 2
2 3
5 2
10 1
12 2
Upvotes: 0
Views: 95
Reputation: 917
I'm not sure if the formatting of the result is important to you, but the following link might come in handy. How can I count the occurrences of each element in a vector in MATLAB?
It's an answer to a similar question on the MathWorks website by their support team. They say there is no single function for it, but they provide 3 options.
Upvotes: 1