how can I count the number of elements on a vector?
Show older comments
Hello!!!!!
If I have a column lets imagine T=[105;105;105;106;106;106;107;107;107;107] how can I count the number of different elements in T? in this case 105 is 3 times, 106 appears 3 times and 107 is 4 times in T.
Thanks!!!
Accepted Answer
More Answers (1)
Ahmet Cecen
on 7 May 2016
Edited: Ahmet Cecen
on 7 May 2016
[C,ia,ic] = unique(T);
c = hist(ic,1:max(ic));
CountArray = [T(ia) c'];
Categories
Find more on Creating and Concatenating Matrices 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!