title: Changing diagonal values if equal to 1
body: <p>I want to change the diagonal values if equal to 1.
  is it possible to look for diagonals and change the values in this particular diagonal to another value.</p>
  
  <p>For example:</p>
  
  <pre><code>X =
  
       1     1     1     0
       1     1     0     1
       1     0     1     1
       0     1     1     1 
  </code></pre>
  
  <p>I want to change this diagonal : </p>
  
  <pre class="lang-none prettyprint-override"><code>    1
      0
      1
  </code></pre>
  
  <p>to</p>
  
  <pre class="lang-none prettyprint-override"><code>    2.2
      0
      2.2
  </code></pre>
  
  <p>I tried:</p>
  
  <pre><code>XX(logical(eye(size(XX)))) = 2
  </code></pre>
  
  <p>but this will change all the values not only ones.</p>
  
  <p>Could you please explain how to do that for other diagonals?</p>