Cody

# Problem 314. Find the sum of the elements in the "second" diagonal

Solution 88928

Submitted on 15 May 2012 by Sunil Kallur Ramegowda
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% x = magic(6); y_correct = 111; assert(isequal(sum_of_sec_diag(x),y_correct))

y = 24 y = 24 23 y = 24 23 22 y = 24 23 22 33 y = 24 23 22 33 5 y = 24 23 22 33 5 4

2   Pass
%% x = magic(10); y_correct = 505; assert(isequal(sum_of_sec_diag(x),y_correct))

y = 40 y = 40 64 y = 40 64 63 y = 40 64 63 62 y = 40 64 63 62 61 y = 40 64 63 62 61 90 y = 40 64 63 62 61 90 89 y = 40 64 63 62 61 90 89 13 y = 40 64 63 62 61 90 89 13 12 y = 40 64 63 62 61 90 89 13 12 11

3   Pass
%% x = magic(11); y_correct = 671; assert(isequal(sum_of_sec_diag(x),y_correct))

y = 66 y = 66 65 y = 66 65 64 y = 66 65 64 63 y = 66 65 64 63 62 y = 66 65 64 63 62 61 y = 66 65 64 63 62 61 60 y = 66 65 64 63 62 61 60 59 y = 66 65 64 63 62 61 60 59 58 y = 66 65 64 63 62 61 60 59 58 57 y = Columns 1 through 10 66 65 64 63 62 61 60 59 58 57 Column 11 56

4   Pass
%% x=[1 2 3; 4 4 6; 2 8 9]; y_correct = 9; assert(isequal(sum_of_sec_diag(x),y_correct))

y = 3 y = 3 4 y = 3 4 2

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!