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 1860165

Submitted on 28 Jun 2019 by kashish sharma
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))

a = 1 1 y = 0 0 0 0 1 0 0 0 0

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

a = 4 5 y = 0 0 0 0 0 0 0 0 9 10 7 6 5 0 0 7 6 2 2 3 0 0 8 6 2 10 10 0 0 10 9 4 7 3 0 0 0 0 0 0 0 0

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

a = 4 5 y = 0 0 0 0 0 0 0 0 3 6 5 5 4 0 0 5 4 1 10 2 0 0 8 1 3 1 8 0 0 4 6 3 3 4 0 0 0 0 0 0 0 0

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

a = 4 5 y = 0 0 0 0 0 0 0 0 2 9 10 10 7 0 0 8 7 8 3 10 0 0 1 4 9 4 1 0 0 7 3 2 1 8 0 0 0 0 0 0 0 0

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

a = 4 5 y = 0 0 0 0 0 0 0 0 10 3 10 4 10 0 0 7 7 5 8 7 0 0 5 6 10 3 8 0 0 6 8 5 8 9 0 0 0 0 0 0 0 0

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

a = 4 5 y = 0 0 0 0 0 0 0 0 8 5 10 9 6 0 0 8 4 6 9 1 0 0 10 8 3 8 8 0 0 1 8 3 8 3 0 0 0 0 0 0 0 0

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

a = 4 5 y = 0 0 0 0 0 0 0 0 9 6 1 9 10 0 0 3 10 7 3 8 0 0 10 2 5 7 6 0 0 4 2 2 10 6 0 0 0 0 0 0 0 0