MATLAB Answers

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

2 views (last 30 days)
Alvaro MInguez
Alvaro MInguez on 9 Dec 2019
Edited: Adam Danz on 11 Dec 2019
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.

  0 Comments

Sign in to comment.

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));

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags