Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 71899

Submitted on 6 Apr 2012 by Bruce Raine

Correct

23Size
Leading solution size is 11.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%% test 1
M=magic(5);
y_correct = [9, 24,1,8 ,15; 23 ,21,7,14,16; 4,6,13,20,22; 10,12,19,5,3; 11,18,25,2,17];
assert(isequal(flipDiagonal(M),y_correct))
x =
     9    24     1     8    15
    23    21     7    14    16
     4     6    13    20    22
    10    12    19     5     3
    11    18    25     2    17
2
Pass
 
%% test 2
m=magic(2);
y_correct=[2 3; 4 1];
assert(isequal(flipDiagonal(m),y_correct))
x =
     2     3
     4     1