This solution is outdated. To rescore this solution, sign in.
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
x = [];
y_correct = [];
assert(isequal(upAndDown(x),y_correct))
b =
[]
c =
[]
y =
[]
|
2 | Pass |
x = 0;
y_correct = [0;0];
assert(isequal(upAndDown(x),y_correct))
b =
0
c =
0
y =
0
0
|
3 | Pass |
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))
b =
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 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 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0
c =
0 0 0 1 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 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 0 0
0 0 0 0 0 0 0 0 0 0
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 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 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0
0 0 0 1 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 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 0 0
0 0 0 0 0 0 0 0 0 0
|
4 | Pass |
x = [1 2 3 4];
y_correct = [1 2 3 4; 1 2 3 4];
assert(isequal(upAndDown(x),y_correct))
b =
1 2 3 4
c =
1 2 3 4
y =
1 2 3 4
1 2 3 4
|
5 | Pass |
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))
b =
2 1 3 2
8 6 5 9
9 9 9 9
c =
9 9 9 9
8 6 5 9
2 1 3 2
y =
2 1 3 2
8 6 5 9
9 9 9 9
9 9 9 9
8 6 5 9
2 1 3 2
|
6 | Pass |
x = 1:10;
y_correct = [x; x];
assert(isequal(upAndDown(x),y_correct))
b =
1 2 3 4 5 6 7 8 9 10
c =
1 2 3 4 5 6 7 8 9 10
y =
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
|
7 | Pass |
x = (1:10)';
y_correct = [x; flipud(x)];
assert(isequal(upAndDown(x),y_correct))
b =
1
2
3
4
5
6
7
8
9
10
c =
10
9
8
7
6
5
4
3
2
1
y =
1
2
3
4
5
6
7
8
9
10
10
9
8
7
6
5
4
3
2
1
|
8 | Pass |
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))
b =
1 4 7
2 5 8
3 6 9
c =
3 6 9
2 5 8
1 4 7
y =
1 4 7
2 5 8
3 6 9
3 6 9
2 5 8
1 4 7
|
Swap the first and last columns
12413 Solvers
321 Solvers
282 Solvers
Create a two dimensional zero matrix
354 Solvers
Element by element multiplication of two vectors
268 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!