Effacer les filtres
Effacer les filtres

Finding the number of values bigger than a certain number in an array?

26 vues (au cours des 30 derniers jours)
James Newton
James Newton le 26 Sep 2012
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.

Réponse acceptée

Tom
Tom le 26 Sep 2012
Modifié(e) : Tom le 26 Sep 2012
x=50*rand(7);
a= x > 21;
numel(a(a>0))
  2 commentaires
Jan
Jan le 26 Sep 2012
Modifié(e) : Andrei Bobrov le 26 Sep 2012
Or: sum(a(:) > 0)
Image Analyst
Image Analyst le 26 Sep 2012
Modifié(e) : Andrei Bobrov le 26 Sep 2012
Or
numberBigger = sum(x(:)>21);
numberSmaller = sum(x(:)<=21);

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by