Cody

# Problem 44401. Vertical matrix sort

Solution 2043338

Submitted on 3 Dec 2019
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   Fail
x = []; y_correct = []; assert(isequal(upAndDown(x),y_correct))

Error using sort Dimension argument must be a positive integer. Error in upAndDown (line 3) y=sort('ascend',x); Error in Test1 (line 3) assert(isequal(upAndDown(x),y_correct))

2   Fail
x = 0; y_correct = [0;0]; assert(isequal(upAndDown(x),y_correct))

Error using sort Dimension argument must be a positive integer. Error in upAndDown (line 3) y=sort('ascend',x); Error in Test2 (line 3) assert(isequal(upAndDown(x),y_correct))

3   Fail
x = zeros(10); x(7,4) = 1; y_correct = zeros(20,10); y_correct(10:11,4) = [1;1]; assert(isequal(upAndDown(x),y_correct))

Error using sort Dimension argument must be a positive integer. Error in upAndDown (line 3) y=sort('ascend',x); Error in Test3 (line 5) assert(isequal(upAndDown(x),y_correct))

4   Fail
x = [1 4 3 2]; y_correct = [1 4 3 2; 1 4 3 2]; assert(isequal(upAndDown(x),y_correct))

Error using sort Dimension argument must be a positive integer. Error in upAndDown (line 3) y=sort('ascend',x); Error in Test4 (line 3) assert(isequal(upAndDown(x),y_correct))

5   Fail
x = [8 9 3 9; 9 6 5 2; 2 1 9 9]; y_correct = [2 1 3 2; 8 6 5 9; 9 9 9 9; 9 9 9 9; 8 6 5 9; 2 1 3 2]; assert(isequal(upAndDown(x),y_correct))

Error using sort Dimension argument must be a positive integer. Error in upAndDown (line 3) y=sort('ascend',x); Error in Test5 (line 4) assert(isequal(upAndDown(x),y_correct))

6   Fail
x = 1:10; y_correct = [x; x]; assert(isequal(upAndDown(x),y_correct))

Error using sort Dimension argument must be a positive integer. Error in upAndDown (line 3) y=sort('ascend',x); Error in Test6 (line 3) assert(isequal(upAndDown(x),y_correct))

7   Fail
x = (1:10)'; y_correct = [x; flipud(x)]; assert(isequal(upAndDown(x),y_correct))

Error using sort Dimension argument must be a positive integer. Error in upAndDown (line 3) y=sort('ascend',x); Error in Test7 (line 3) assert(isequal(upAndDown(x),y_correct))

8   Fail
x = reshape(1:9,[3,3]); c = [1:3,3:-1:1]'; y_correct = [c,c+3,c+6]; assert(isequal(upAndDown(x),y_correct))

Error using sort Dimension argument must be a positive integer. Error in upAndDown (line 3) y=sort('ascend',x); Error in Test8 (line 4) assert(isequal(upAndDown(x),y_correct))