Count values in the given array
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Turbulence Analysis
am 21 Okt. 2023
Kommentiert: Star Strider
am 21 Okt. 2023
Hi,
In the attached array, column 1 got two values -3.14 and -3.84 and on column 2 some values are 0 and some are 1. I need to check how many zeros and 1 are in -3.14 and -3.84.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 21 Okt. 2023
Bearbeitet: Star Strider
am 21 Okt. 2023
Try this —
LD = load('matlab.mat');
AA4 = LD.AA4
[UAA4,ix1,ix2] = unique(AA4(:,1));
Zeros = accumarray(ix2, (1:numel(ix2))', [], @(x)nnz(AA4(x,2) == 0));
Ones = accumarray(ix2, (1:numel(ix2))', [], @(x)nnz(AA4(x,2) == 1));
NrZeros = table(UAA4, Zeros, Ones)
.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!