Finding the number of values bigger than a certain number in an array?
26 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Tom
il 26 Set 2012
Modificato: Tom
il 26 Set 2012
x=50*rand(7);
a= x > 21;
numel(a(a>0))
2 Commenti
Image Analyst
il 26 Set 2012
Modificato: Andrei Bobrov
il 26 Set 2012
Or
numberBigger = sum(x(:)>21);
numberSmaller = sum(x(:)<=21);
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!