Finding the number of values bigger than a certain number in an array?
26 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Suppose I have an array of 50 numbers, how would I find the number of elements bigger than say 21 in an array of random numbers? Conversely, for less than as well.
0 Kommentare
Akzeptierte Antwort
Tom
am 26 Sep. 2012
Bearbeitet: Tom
am 26 Sep. 2012
x=50*rand(7);
a= x > 21;
numel(a(a>0))
2 Kommentare
Image Analyst
am 26 Sep. 2012
Bearbeitet: Andrei Bobrov
am 26 Sep. 2012
Or
numberBigger = sum(x(:)>21);
numberSmaller = sum(x(:)<=21);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating 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!