Problem 1400. Spiral Matrix
for a given integer n>=3, generate a matrix of nxn such that the value n^2 is at bottom left and its decreasing towards center around the corner forming a spiral.{clockwise spiral- starting from bottom left}
Examples:
 Input  n = 5
 Output y is [ 21 20 19 18 17;
               22 7  6  5  16;
               23 8  1  4  15;
               24 9  2  3  14;
               25 10 11 12 13]; Input  n = 4
 Output y is [ 13 12 11 10 
               14 3  2  9
               15 4  1  8
               16 5  6  7]
			Solution Stats
Problem Comments
- 
		1 Comment
		Dan
    	on 4 Apr 2013
	
	
  	If input must ber an integer n>=3, why in the test suite there are n=1 and n=2 cases?
Solution Comments
Show commentsProblem Recent Solvers80
Suggested Problems
- 
         Remove any row in which a NaN appears 8695 Solvers 
- 
         Remove the small words from a list of words. 1544 Solvers 
- 
         Back to basics 22 - Rotate a matrix 922 Solvers 
- 
         Create matrix of replicated elements 387 Solvers 
- 
         
         546 Solvers 
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!