Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
x = ones(4,4);
y_correct = [1 0 0 0; 1 1 0 0; 1 1 1 0; 1 1 1 1];
assert(isequal(triangle(x),y_correct))
m =
4
n =
4
1 0 0 0
1 1 0 0
1 1 1 0
1 1 1 1
y =
1 0 0 0
1 1 0 0
1 1 1 0
1 1 1 1
|
2 | Pass |
x = ones(5,5);
y_correct = [1 0 0 0 0; 1 1 0 0 0; 1 1 1 0 0; 1 1 1 1 0; 1 1 1 1 1];
assert(isequal(triangle(x),y_correct))
m =
5
n =
5
1 0 0 0 0
1 1 0 0 0
1 1 1 0 0
1 1 1 1 0
1 1 1 1 1
y =
1 0 0 0 0
1 1 0 0 0
1 1 1 0 0
1 1 1 1 0
1 1 1 1 1
|
3 | Pass |
x = reshape(1:16,[4,4]);
y_correct = [1 2 3 4; 0 6 7 8; 0 0 11 12; 0 0 0 16]';
assert(isequal(triangle(x),y_correct))
m =
4
n =
4
1 0 0 0
2 6 0 0
3 7 11 0
4 8 12 16
y =
1 0 0 0
2 6 0 0
3 7 11 0
4 8 12 16
|
4 | Pass |
x = [0 1 2 3; 0 0 1 2; 0 0 0 1; 0 0 0 0];
y_correct = zeros(4);
assert(isequal(triangle(x),y_correct))
m =
4
n =
4
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
|
Find the sum of all the numbers of the input vector
31943 Solvers
27983 Solvers
1091 Solvers
381 Solvers
Remove the two elements next to NaN value
411 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!