Finding the number of values bigger than a certain number in an array?

36 views (last 30 days)
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.

Accepted Answer

Tom
Tom on 26 Sep 2012
Edited: Tom on 26 Sep 2012
x=50*rand(7);
a= x > 21;
numel(a(a>0))

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!