Compute the sum of diagonal elements of a square matrix and store the larger sum to s.
Eg : a = [1 2 3; 2 3 4; 4 5 10]
sum of diagonal 1 = 1+3+10=14
sum of diagonal 2 = 3+3+4=10
s=14
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers54
Suggested Problems
-
2475 Solvers
-
Project Euler: Problem 5, Smallest multiple
1677 Solvers
-
Who knows the last digit of pi?
692 Solvers
-
Matrix indexing with two vectors of indices
782 Solvers
-
Get the length of a given vector
13650 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!