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 579. Spiral In

Created by Nicholas Howe

Create an m by n matrix filled with sequential integers starting from 1 and arranged in a counterclockwise spiral that hugs the outside border and begins in the upper left corner.

For example:

>> spiralIn(4,5)
ans =
   1    14    13    12    11
   2    15    20    19    10
   3    16    17    18     9
   4     5     6     7     8

Problem Group

Solution Statistics

16 correct solutions 21 incorrect solutions
Last solution submitted on Jul 11, 2013

Problem Comments