MATLAB: Calculate the percentage of zeros and ones each row of matrix
matrixpercentagerows
Hello,
I have a 42×3 matrix containing zeros and ones. I want to find the percentage of each row in this matrix. What is the most efficient way to do so?
Thank you in advance.
Shannon
Best Answer
percentOnes = sum( myMatrix, 2 ) / 3 * 100;
percentZeros = 100 - percentOnes;
That is, assuming what you mean by 'I want to find the percentage of each row in this matrix' is that you want to find the percentage of ones and of zeros in each row.
Best Answer