how calculate percentage with a vector and a matrix with nan elements?
Show older comments
I have a vector V where each element of V is bigger than zero, and a matrix M where each row represent data, each column the source of the data, and each element the number of errors.
A small example will be:
V=[10 5 4 8];
M=[0 2 NaN 4 ;
0 0 3 2 ;
0 NaN 0 1 ;
0 2 NaN 0 ];
I would like to calculate a vector P with the percentage or error without for loops and without consider the part of the matrix with NaN elements such as
P=[((0+0+0+0)/(10+5+4+8))*100 ((2+0+2)/(10+5+8))*100 ((3+0)/(5+4))*100 ((4+2+1+0)/(10+5+4+8))*100]
P=[ 0 17.3913 33.3333 25.9259]
Accepted Answer
More Answers (0)
Categories
Find more on NaNs 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!