This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
x = magic(4);
y_correct = sum(diag(x));
assert(isequal(your_fcn_name(x),y_correct))
a =
4
m =
136
x =
0 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
x =
0 2 3 13
5 0 10 8
9 7 6 12
4 14 15 1
x =
0 2 3 13
5 0 10 8
9 7 0 12
4 14 15 1
x =
0 2 3 13
5 0 10 8
9 7 0 12
4 14 15 0
n =
102
y =
34
|
2 | Pass |
x = ones(5);
y_correct = sum(diag(x));
assert(isequal(your_fcn_name(x),y_correct))
a =
5
m =
25
x =
0 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
x =
0 1 1 1 1
1 0 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
x =
0 1 1 1 1
1 0 1 1 1
1 1 0 1 1
1 1 1 1 1
1 1 1 1 1
x =
0 1 1 1 1
1 0 1 1 1
1 1 0 1 1
1 1 1 0 1
1 1 1 1 1
x =
0 1 1 1 1
1 0 1 1 1
1 1 0 1 1
1 1 1 0 1
1 1 1 1 0
n =
20
y =
5
|
Arrange Vector in descending order
4080 Solvers
390 Solvers
367 Solvers
241 Solvers
Back to Basics - Find no. of elements in a matrix?
216 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!