Cody

# Problem 792. Set some matrix elements to zero

Solution 2259087

Submitted on 6 May 2020
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   Fail
x = [1 2 3 4 5 5 6 5 7 9 8 3]; y_correct = [0 0 0 4 0 0 6 0 0 9 0 0]; assert(isequal(your_fcn_name(x),y_correct))

v = 6 8 10

Error using zeros Size vector should be a row vector with real elements. Error in your_fcn_name (line 3) y=zeros(x); y(v)=x(v); Error in Test1 (line 7) assert(isequal(your_fcn_name(x),y_correct))

2   Fail
x = magic(4); y_correct = [16 0 0 0 0 11 0 0 0 0 0 12 0 0 15 0]; assert(isequal(your_fcn_name(x),y_correct))

v = 1 6 12 15

Error using zeros Size vector should be a row vector with real elements. Error in your_fcn_name (line 3) y=zeros(x); y(v)=x(v); Error in Test2 (line 6) assert(isequal(your_fcn_name(x),y_correct))

3   Fail
x = pi; y_correct = pi; assert(isequal(your_fcn_name(x),y_correct))

v = 1

Error using zeros Size inputs must be integers. Error in your_fcn_name (line 3) y=zeros(x); y(v)=x(v); Error in Test3 (line 3) assert(isequal(your_fcn_name(x),y_correct))

4   Pass
x = 0; y_correct = 0; assert(isequal(your_fcn_name(x),y_correct))

v = 1

5   Fail
x = toeplitz(1:5); y_correct = [ 0 0 0 0 5 0 0 0 0 4 3 0 0 0 0 4 0 0 0 0 5 0 0 0 0]; assert(isequal(your_fcn_name(x),y_correct))

v = 3 4 5 21 22

Error using zeros Size vector should be a row vector with real elements. Error in your_fcn_name (line 3) y=zeros(x); y(v)=x(v); Error in Test5 (line 7) assert(isequal(your_fcn_name(x),y_correct))

6   Fail
x = ones(5); y_correct = [ 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0]; assert(isequal(your_fcn_name(x),y_correct))

v = 1 2 3 4 5

Error using zeros Size vector should be a row vector with real elements. Error in your_fcn_name (line 3) y=zeros(x); y(v)=x(v); Error in Test6 (line 7) assert(isequal(your_fcn_name(x),y_correct))

7   Fail
x =nchoosek(7:9,3); y_correct =[ 0 0 9]; assert(isequal(your_fcn_name(x),y_correct))

v = 3

Assertion failed.

8   Fail
x =nchoosek(4:9,2); y_correct = [ 0 5 0 6 0 7 0 8 0 9 0 6 0 7 0 8 0 9 0 7 0 8 0 9 0 8 0 9 0 9]; assert(isequal(your_fcn_name(x),y_correct))

v = 16 17

Error using zeros Size vector should be a row vector with real elements. Error in your_fcn_name (line 3) y=zeros(x); y(v)=x(v); Error in Test8 (line 17) assert(isequal(your_fcn_name(x),y_correct))