Cody

# Problem 792. Set some matrix elements to zero

Solution 535753

Submitted on 26 Nov 2014 by Abdullah Caliskan
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
%% 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))

MM = [] k = 4 p = 4 M = 0 0 0 0 k = 6 p = 3 M = 0 0 0 0 k = 9 p = 2 M = 0 0 0 0

2   Pass
%% 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))

MM = [] k = 16 p = 1 M = 0 0 0 0 k = 11 p = 2 M = 0 0 0 0 k = 12 p = 4 M = 0 0 0 0 k = 15 p = 3 M = 0 0 0 0

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

MM = [] k = 3.1416 p = 1 M = 0

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

MM = [] k = 0 p = 1 M = 0

5   Pass
%% 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))

MM = [] k = 5 p = 5 M = 0 0 0 0 0 k = 4 p = 5 M = 0 0 0 0 0 k = 3 p = 1 M = 0 0 0 0 0 k = 4 p = 1 M = 0 0 0 0 0 k = 5 p = 1 M = 0 0 0 0 0

6   Pass
%% 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))

MM = [] k = 1 p = 1 M = 0 0 0 0 0 k = 1 p = 1 M = 0 0 0 0 0 k = 1 p = 1 M = 0 0 0 0 0 k = 1 p = 1 M = 0 0 0 0 0 k = 1 p = 1 M = 0 0 0 0 0

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

MM = [] k = 9 p = 3 M = 0 0 0

8   Pass
%% 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))

MM = [] k = 5 p = 2 M = 0 0 k = 6 p = 2 M = 0 0 k = 7 p = 2 M = 0 0 k = 8 p = 2 M = 0 0 k = 9 p = 2 M = 0 0 k = 6 p = 2 M = 0 0 k = 7 p = 2 M = 0 0 k = 8 p = 2 M = 0 0 k = 9 p = 2 M = 0 0 k = 7 p = 2 M = 0 0 k = 8 p = 2 M = 0 0 k = 9 p = 2 M = 0 0 k = 8 p = 2 M = 0 0 k = 9 p = 2 M = 0 0 k = 9 p = 2 M = 0 0

### Community Treasure Hunt

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

Start Hunting!