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 1812875

Submitted on 11 May 2019 by maya abu fowdah
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))

m = 1 n = 1 y = 0 0 0 0 0 0 0 0 0 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))

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

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

m = 4 n = 5 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 5 2 9 1 9 0 0 1 7 4 7 6 0 0 9 5 2 8 5 0 0 6 2 4 8 1 0 0 0 0 0 0 0 0

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

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

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

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

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

m = 4 n = 5 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 1 4 4 7 5 0 0 9 5 3 4 2 0 0 4 1 9 3 8 0 0 6 6 7 3 8 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)))

m = 4 n = 5 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 2 5 8 8 8 0 0 10 7 1 1 6 0 0 7 2 10 6 9 0 0 5 5 1 2 2 0 0 0 0 0 0 0 0