How can I find the parcentage of values in a vector that are bigger than 5.

1 view (last 30 days)
Let's imagine I have a given vector and I want to calculate the number of values in that vector that are bigger than 5 for example. Wich is the condition or the way to sum up those values and do the percentage? Thanks.

Answers (1)

Adam Danz
Adam Danz on 9 Dec 2019
Edited: Adam Danz on 11 Dec 2019
" I want to calculate the number of values in that vector that are bigger than 5"
p = sum(v>5)/numel(v);
If there are NaN values you'd like to ignore,
p = sum(v>5)/sum(~isnan(v));

Tags

Community Treasure Hunt

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

Start Hunting!