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

1 次查看(过去 30 天)
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.

回答(1 个)

Adam Danz
Adam Danz 2019-12-9
编辑:Adam Danz 2019-12-11
" 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));

类别

Help CenterFile Exchange 中查找有关 NaNs 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by