Finding the number of values bigger than a certain number in an array?
26 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
採用された回答
Tom
2012 年 9 月 26 日
編集済み: Tom
2012 年 9 月 26 日
x=50*rand(7);
a= x > 21;
numel(a(a>0))
2 件のコメント
Image Analyst
2012 年 9 月 26 日
編集済み: Andrei Bobrov
2012 年 9 月 26 日
Or
numberBigger = sum(x(:)>21);
numberSmaller = sum(x(:)<=21);
その他の回答 (0 件)
参考
カテゴリ
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!