Borrar filtros
Borrar filtros

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

26 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Tom
Tom el 26 de Sept. de 2012
Editada: Tom el 26 de Sept. de 2012
x=50*rand(7);
a= x > 21;
numel(a(a>0))
  2 comentarios
Jan
Jan el 26 de Sept. de 2012
Editada: Andrei Bobrov el 26 de Sept. de 2012
Or: sum(a(:) > 0)
Image Analyst
Image Analyst el 26 de Sept. de 2012
Editada: Andrei Bobrov el 26 de Sept. de 2012
Or
numberBigger = sum(x(:)>21);
numberSmaller = sum(x(:)<=21);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by