title: how to find upper and lower diagonal matrix matlab
body: <p>I tried to use matlab to find the upper and lower diagonal matrix in matlab</p>
  
  <p>here is the idea</p>
  
  <p>if I have matrix 4x4</p>
  
  <pre><code> 1  2  3  4 
   5  6  7  8
   9 10 11 12 
  13 14 15 16
  </code></pre>
  
  <p>the main diagonal is </p>
  
  <pre><code>1 6 11 16
  </code></pre>
  
  <p>but the second upper diagonal is </p>
  
  <pre><code>2 7 12
  </code></pre>
  
  <p>and the lower is</p>
  
  <pre><code>5 10 15
  </code></pre>
  
  <p>so there is <code>triu</code> and <code>tril</code> but to to write it or use any other function in matlab to find this upper and lower diagonal in matrix.</p>