title: How do I create this matrix in Matlab?
body: <p>I'm attempting to solve the <a href="https://stackoverflow.com/questions/3365487/code-golf-build-me-an-arc/3369332#3369332">Code Golf: Build Me an Arc</a> problem. My solution's not bad, but I figure, there's a simpler way to do it. Does anybody know how to generate an <code>nxn</code> matrix like this, given <code>n</code>? I spent 57 characters getting it!</p>
  <pre><code> 3     0     0     0     2     0     0     0     1
   0     3     0     0     2     0     0     1     0
   0     0     3     0     2     0     1     0     0
   0     0     0     3     2     1     0     0     0
   4     4     4     4     8     8     8     8     8
   0     0     0     5     6     7     0     0     0
   0     0     5     0     6     0     7     0     0
   0     5     0     0     6     0     0     7     0
   5     0     0     0     6     0     0     0     7
  </code></pre>
  <p>I would like to beat some of these <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/f16-5872.html#f16-6070" rel="nofollow noreferrer">matrices</a> into shape.</p>
  <h3>Update:</h3>
  <p>This is how I get it now.</p>
  <pre><code>%%# Create the grid
  [X Y]=meshgrid(-r:r);
  %%# Compute the angles in degrees
  T=atan2(-Y,X)/pi*180;
  %%# Get all the angles
  T=T+(T&lt;=0)*360;
  </code></pre>
  <p>As you can see, I don't need most of the entries in <code>T</code>.</p>