Compute the sum of the diagonal elements of an array (vector or matrix).
If array is not square return the char array: 'no-square'
If the input is empty, return [].
If the input is a scalar return the scalar number.
If any diagonal element is NaN, return NaN.
If any diagonal element is Inf, return Inf.
If both NaN and Inf appear among the diagonal, return -1.
Some built-in functions are forbidden.
Solution Stats
Solution Comments
Show comments
Loading...
Problem Recent Solvers3
Suggested Problems
More from this Author9
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!