title: convert 1d to 2d matrix using zigzag ordering
body: <p>I have an 1D matrix in MATLAB that in created with best answer of mentioned question below, I would like to reorder it to first array:</p>
  
  <p><a href="https://stackoverflow.com/questions/3024939/matrix-zigzag-reordering">Matrix &quot;Zigzag&quot; Reordering</a></p>
  
  <p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/JPEG_ZigZag.svg/220px-JPEG_ZigZag.svg.png" alt="zigzag layout pattern"> 
  Source: <a href="http://en.wikipedia.org/wiki/JPEG" rel="nofollow noreferrer">Wikidpedia: Jpeg</a></p>
  
  <pre><code>m = [69     9    75    46    23    16   100    83    92    54     8    45];
  
  zigzag_writing(m, 4, 3)
  </code></pre>
  
  <p>ans=</p>
  
  <pre><code>69     9    16   100
  75    23    83     8
  46    92    54    45
  </code></pre>