How to group arrays in matrix
6 views (last 30 days)
Show older comments
Matrix A as follows:
A = [
1
1
1
2
2
4
4
7
8
8
9
];
I want to group by matrix A as follows:
B = [
1 3
2 2
4 2
7 1
8 2
9 1
];
1 Comment
Stephen23
on 10 Apr 2017
The old fashioned way:
>> U = unique(A);
>> [U,hist(A,U).']
ans =
1 3
2 2
4 2
7 1
8 2
9 1
Answers (2)
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!