Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
x = [1:4];
y_correct = [1 0 0 0; 0 2 0 0; 0 0 3 0; 0 0 0 4];
assert(isequal(diag_array(x),y_correct))
m =
1
n =
4
a =
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
a =
1 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
a =
1 0 0 0
0 2 0 0
0 0 0 0
0 0 0 0
a =
1 0 0 0
0 2 0 0
0 0 3 0
0 0 0 0
a =
1 0 0 0
0 2 0 0
0 0 3 0
0 0 0 4
|
2 | Pass |
x = [100 23 3.14 12 200];
y_correct = [100.0000 0 0 0 0;
0 23.0000 0 0 0;
0 0 3.1400 0 0;
0 0 0 12.0000 0;
0 0 0 0 200.0000]
assert(isequal(diag_array(x),y_correct))
y_correct =
100.0000 0 0 0 0
0 23.0000 0 0 0
0 0 3.1400 0 0
0 0 0 12.0000 0
0 0 0 0 200.0000
m =
1
n =
5
a =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
a =
100 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
a =
100 0 0 0 0
0 23 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
a =
100.0000 0 0 0 0
0 23.0000 0 0 0
0 0 3.1400 0 0
0 0 0 0 0
0 0 0 0 0
a =
100.0000 0 0 0 0
0 23.0000 0 0 0
0 0 3.1400 0 0
0 0 0 12.0000 0
0 0 0 0 0
a =
100.0000 0 0 0 0
0 23.0000 0 0 0
0 0 3.1400 0 0
0 0 0 12.0000 0
0 0 0 0 200.0000
|
405 Solvers
Back to basics 12 - Input Arguments
525 Solvers
Return the first and last character of a string
3447 Solvers
965 Solvers
309 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!