Cody

# Problem 44887. Given a matrix A (size m x n) create a matrix B (size m+2 x n+2) which consists of matrix A surrounded by zeros. See Example below:

Solution 1807665

Submitted on 6 May 2019 by bentzi grinfeld
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]; y_correct = [0 0 0 0 1 0 0 0 0]; assert(isequal(zeroWrap(x),y_correct))

n = 1 m = 1 b = 0 0 0 r = 0 1 0

2   Pass
x = randi(10,4,5); m=zeroWrap(x); assert(isequal(m(2:end-1,2:end-1),x))

n = 4 m = 5 b = 0 0 0 0 0 0 0 r = 0 2 2 2 4 3 0 0 1 1 6 8 4 0 0 5 2 1 2 4 0 0 9 10 4 3 6 0

3   Pass
x = randi(10,4,5); m=zeroWrap(x); assert(isequal(sum(m(1,:)),0))

n = 4 m = 5 b = 0 0 0 0 0 0 0 r = 0 6 3 7 3 6 0 0 10 4 7 4 6 0 0 9 8 2 5 9 0 0 3 9 9 10 3 0

4   Pass
x = randi(10,4,5); m=zeroWrap(x); assert(isequal(sum(m(end,:)),0))

n = 4 m = 5 b = 0 0 0 0 0 0 0 r = 0 7 10 1 6 9 0 0 10 5 3 2 6 0 0 2 7 3 6 8 0 0 10 8 6 7 2 0

5   Pass
x = randi(10,4,5); m=zeroWrap(x); assert(isequal(sum(m(:,1)),0))

n = 4 m = 5 b = 0 0 0 0 0 0 0 r = 0 5 1 6 8 2 0 0 8 8 7 2 5 0 0 10 3 8 10 5 0 0 9 7 6 6 8 0

6   Pass
x = randi(10,4,5); m=zeroWrap(x); assert(isequal(sum(m(:,end)),0))

n = 4 m = 5 b = 0 0 0 0 0 0 0 r = 0 4 7 2 9 9 0 0 10 2 3 1 5 0 0 2 3 8 5 1 0 0 10 4 6 3 4 0

7   Pass
x = randi(10,4,5); m=zeroWrap(x); assert(isequal(size(m)-2,size(x)))

n = 4 m = 5 b = 0 0 0 0 0 0 0 r = 0 3 9 8 2 10 0 0 4 9 2 10 8 0 0 7 8 2 7 5 0 0 6 2 10 7 10 0