Count Numbers between two values in random vectors
39 ビュー (過去 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!