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 173627

Submitted on 6 Dec 2012 by @bmtran

Correct

125Size
Leading solution size is 19.
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
 
%%
dem = [1 5 9; ...
       4 5 6; ...
       8 7 3];
IX  = [0 1 4; ...
       1 1 9; ...
       2 9 0];
assert(isequal(sgix(dem),IX))

                    
2
Pass
 
%%
dem = [1 5 4 9; ...
       4 5 7 7; ...
       6 6 6 8];
IX  = [0 1 0 7; ...
       1 1 7 7; ...
       2 2 5 9];
assert(isequal(sgix(dem),IX))