Counting amount of digit occurrence in a cell
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
M
am 11 Mai 2021
Beantwortet: Star Strider
am 11 Mai 2021
I have this cell just with simple numbers, and I would like to count how many times each digit is repeated in this whole celll, so for example if this one would've had just 9 rows, as an output I'd like to see that i have seven two's, one three and one nine.
Akzeptierte Antwort
Star Strider
am 11 Mai 2021
Try something like this —
CellArray = num2cell([2; 2; 2; 2; 2; 2; 2; 3; 9]);
[Uc,~,ix] = unique([CellArray{:}],'stable');
Count = accumarray(ix,1);
Col1 = Uc(:);
Result = table(Col1,Count)
.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Functions 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!