How can i find,most and less reapted number in array or matrix?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Farhad
am 20 Mai 2015
Kommentiert: Farhad
am 20 Mai 2015
i have a matrix like:X=[1 3 3 3 3; 3 7 4 4 4; 4 7 5 5 5; 5 9 8 8 8 ] in this matrix most repeated number is 3 and less repeated number is 1 and 9.i want to sort number by times of repeated.how can i do this? Thanks
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 20 Mai 2015
X=[1 3 3 3 3; 3 7 4 4 4; 4 7 5 5 5; 5 9 8 8 8 ];
c = unique(X(:));
z = histc(X(:),c);
out = sortrows([c,z],2);
Weitere Antworten (1)
Image Analyst
am 20 Mai 2015
Is this homework? Sounds like it. Why not try histcounts()? Or histc if you have an old version of MATLAB. It's a good chance to learn about histograms and the several MATLAB functions related to histograms.
Siehe auch
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!