Finding the number of values bigger than a certain number in an array?
16 次查看(过去 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!