title: Implementation of correlation matrix in MATLAB
body: <p>I want to implement the following formula in MATLAB, where u_i^(k) means the i,k element. However, I get different results from the ones I compute by hand... I believe that something is wrong with my MATLAB code. For instance,
  I should get:</p>
  
  <pre><code>L_ii =
  
      0.1022         0         0
           0    0.1657         0
           0         0    2.7321
  
  U_ij =
  
      0.7514    0.3104    0.5823
     -0.6513    0.4901    0.5793
     -0.1055   -0.8145    0.5704
  
  1,1=1-(0.1022*(+0.7514)^2+0.1657*(+0.3104)^2+2.7321*(+0.5823)^2)=-0.000049
  2,2=1-(0.1022*(-0.6513)^2+0.1657*(+0.4901)^2+2.7321*(+0.5793)^2)=-0.000015
  3,3=1-(0.1022*(-0.1055)^2+0.1657*(-0.8145)^2+2.7321*(+0.5704)^2)=+0.000030
  </code></pre>
  
  <p>Any ideas??? Please, help me fix Epsilon first (it might not need to move on Rho. Let's fix Epsilon first...)</p>
  
  <p><img src="https://i.stack.imgur.com/G4kTU.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/ITv2w.png" alt="enter image description here"></p>
  
  <p>EDIT: Here is a sample code:</p>
  
  <pre><code>E_squared_ii = ONES_j - diag(L_ii)' * (U_ij'.^ 2)
  </code></pre>
  
  <p>And here is the <em>wrong</em> result I get at the moment:</p>
  
  <pre><code>E_squared_ii =
  
     1.0e-15 *
  
     0.444089209850063   0.333066907387547  -0.222044604925031
  </code></pre>