Cody

# Problem 1429. Remove entire row and column in the matrix containing the input values

Solution 262975

Submitted on 18 Jun 2013 by Dan
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 = magic(3); n=3; y_correct = [1 6; 9 2]; assert(isequal(mat_remove(x,n),y_correct))

``` ans = [2] ans = 2 a = 2 b = 1 ```

2   Pass
%% x=eye(9); n=[1 0]; y_correct = []; assert(isequal(mat_remove(x,n),y_correct))

``` ans = [1x9 double] [1x72 double] ans = Columns 1 through 16 1 11 21 31 41 51 61 71 81 2 3 4 5 6 7 8 Columns 17 through 32 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 Columns 33 through 48 27 28 29 30 32 33 34 35 36 37 38 39 40 42 43 44 Columns 49 through 64 45 46 47 48 49 50 52 53 54 55 56 57 58 59 60 62 Columns 65 through 80 63 64 65 66 67 68 69 70 72 73 74 75 76 77 78 79 Column 81 80 a = Columns 1 through 16 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 Columns 17 through 32 9 1 3 4 5 6 7 8 9 1 2 4 5 6 7 8 Columns 33 through 48 9 1 2 3 5 6 7 8 9 1 2 3 4 6 7 8 Columns 49 through 64 9 1 2 3 4 5 7 8 9 1 2 3 4 5 6 8 Columns 65 through 80 9 1 2 3 4 5 6 7 9 1 2 3 4 5 6 7 Column 81 8 b = Columns 1 through 16 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 Columns 17 through 32 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 Columns 33 through 48 3 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 Columns 49 through 64 5 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 Columns 65 through 80 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 Column 81 9 ```

3   Pass
%% x=ones(8); n=1; y_correct = []; assert(isequal(mat_remove(x,n),y_correct))

``` ans = [1x64 double] ans = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 48 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 Columns 49 through 64 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 a = Columns 1 through 16 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 Columns 17 through 32 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 Columns 33 through 48 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 Columns 49 through 64 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 b = Columns 1 through 16 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 Columns 17 through 32 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 Columns 33 through 48 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 Columns 49 through 64 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 ```

4   Pass
%% x=spiral(3); n=1; y_correct = [7 9; 5 3]; assert(isequal(mat_remove(x,n),y_correct))

``` ans = [5] ans = 5 a = 2 b = 2 ```