Need to determine the fraction of a matrix of ones and zeroes that are zeroes
1 view (last 30 days)
Show older comments
I need to determine the fraction of a matrix of ones and zeroes that are zeroes.
My code is:
function y = zero_stat(Y)
K=mean(Y');
[x,y] = size(Y');
r = mean(Y',y);
s = sum(r);
y=(1-s)/y)*100;
end
IF 40% of the matrix is comprised of zeroes, the function is to return 40.
0 Comments
Accepted Answer
More Answers (1)
Steven Lord
on 14 Nov 2016
Get the number of nonzeros using nnz and the total number of elements using numel.
0 Comments
See Also
Categories
Find more on Logical 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!