Cody

# Problem 44665. Percentage of zeros in a matrix of only 1s and 0s

Solution 1892657

Submitted on 6 Aug 2019 by liu xinyang
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
inp_matrix = [1,0,0,1,1;0,1,1,0,0;0,0,0,0,0;1,1,1,1,1;1,1,1,1,1]; pct_zero_corr = 40; assert(isequal(zero_stat(inp_matrix),pct_zero_corr))

Vector = 1 0 0 1 1 0 1 0 1 1 0 1 0 1 1 1 0 0 1 1 1 0 0 1 1 z = 0 0 0 0 0 0 0 0 0 0 percent = 0.4000 pct_zero = 40

2   Pass
inp_matrix = diag([1,0,1,1,1]); pct_zero_corr = 84; assert(isequal(zero_stat(inp_matrix),pct_zero_corr))

Vector = 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 z = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 percent = 0.8400 pct_zero = 84

3   Pass
inp_matrix = [1,0,1,0,0,0,1]'; pct_zero_corr = 57; assert(isequal(zero_stat(inp_matrix),pct_zero_corr))

Vector = 1 0 1 0 0 0 1 z = 0 0 0 0 percent = 0.5714 pct_zero = 57

### Community Treasure Hunt

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

Start Hunting!