Given a matrix, return the sum of all the elements across the diagonals.
E.g. A = [1 2 3;
4 5 6;
7 8 9;]
sum = 25 as sum of (1, 3, 7, 9,5)
Basically the same as Problem 1158
only the odds.
Works for current test suite, but not in general.
Try adding an even sized matrix (magic(6), for instance) to the test suite. If the two diagonals don't share any points, a lot of these solutions won't work.
First time I see this notation.
Distance walked 3D
Determine if a Given Number is a Triangle Number
Remove the two elements next to NaN value
07 - Common functions and indexing 4
Element by element multiplication of two vectors
Let's get back to school, and create multiplication tables
Find offset of given matrix element from first matrix element
Matrix to column conversion
Back to basics - mean of corner elements of a matrix
Best Fit RMS
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office