Count Numbers between two values in random vectors
41 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hadi
el 6 de En. de 2015
Comentada: Logan Calkins
el 4 de Jul. de 2021
I am trying to find the how many numbers are between two specific values in a random vector. For example, How many are betweens 1 and 5
A=[1,2,3,4,5]
is should return 3 in this case. So what is the function that allow me to identify this?
0 comentarios
Respuesta aceptada
Titus Edelhofer
el 6 de En. de 2015
Hi,
use logical indexing and count the result:
X = rand(1, 1000);
nBetween05and09 = sum(X>0.5 & X<0.9)
Titus
3 comentarios
Más respuestas (1)
Azzi Abdelmalek
el 6 de En. de 2015
find(A==5)-find(A==1)-1
Ver también
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!