Cody

# Problem 611. surrounded matrix

Solution 257643

Submitted on 7 Jun 2013
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 = ones(3); assert(isequal(surrounded(x),y_correct))

2   Pass
x = [3 3 3;3 3 3]; y_correct = [1 1 1 1 1;1 3 3 3 1; 1 3 3 3 1; 1 1 1 1 1]; assert(isequal(surrounded(x),y_correct))

3   Fail
x = ones(3,4); y_correct = ones(5,6); assert(isequal(surrounded(x),y_correct))

```Error using regexp Evaluation of ' y=ones(length(A)+1+mod(size(A,1),2),length(A)+2);for i=2:size(y,1)-1;for j=2:size(y,2)-1;y(i,j)=A(i-1,j-1);end;end' failed: Index exceeds matrix dimensions. Error in surrounded (line 2) regexp('','(?@ y=ones(length(A)+1+mod(size(A,1),2),length(A)+2);for i=2:size(y,1)-1;for j=2:size(y,2)-1;y(i,j)=A(i-1,j-1);end;end)'); Error in TestPoint3 (line 3) assert(isequal(surrounded(x),y_correct))```

4   Pass
x = [0]; y_correct = ones(3); y_correct(2,2) = 0; assert(isequal(surrounded(x),y_correct))

5   Pass
x = reshape(1:9,[3,3]); y_correct = [1 1 1 1 1; 1 1 2 3 1; ... 1 4 5 6 1; 1 7 8 9 1; 1 1 1 1 1]'; assert(isequal(surrounded(x),y_correct))