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

Problem 364. Matrix spiral

Created by Bart

Make a spiral in a (n*n) matrix. The spiral has to start in the top left, and has to rotate clockwise to the center. The spiral has to have a padding of zeros between itself.

The (n*n) matrix is filled with zeros except for the spiral, that has to be made of 11 (elevens, for visual reference). The final matrix has to have the same or more zeros than elevens.

Example: n=8

A =

    11    11    11    11    11    11    11    11
     0     0     0     0     0     0     0    11
     0     0    11    11    11    11     0    11
     0     0    11     0     0    11     0    11
     0     0    11     0    11    11     0    11
     0     0    11     0     0     0     0    11
     0     0    11    11    11    11    11    11
     0     0     0     0     0     0     0     0

Problem Group

Solution Statistics

23 correct solutions 24 incorrect solutions
Last solution submitted on Feb 20, 2014

Problem Comments

Solution Comments