Count Numbers between two values in random vectors
조회 수: 7 (최근 30일)
이전 댓글 표시
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
채택된 답변
Titus Edelhofer
2015년 1월 6일
Hi,
use logical indexing and count the result:
X = rand(1, 1000);
nBetween05and09 = sum(X>0.5 & X<0.9)
Titus
댓글 수: 3
추가 답변 (1개)
Azzi Abdelmalek
2015년 1월 6일
find(A==5)-find(A==1)-1
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!