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 185798

Submitted on 4 Jan 2013 by J.R.! Menzinger

Correct

69Size
Leading solution size is 33.
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
 
%%
x = [1 2; 3 4];
y_correct = [1 2 3 4];
assert(isequal(zigzag(x),y_correct))

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

                    
3
Pass
 
%%
x = magic(4);
y_correct = [16 2 5 9 11 3 13 10 7 4 14 6 8 12 15 1];
assert(isequal(zigzag(x),y_correct))