title: Matlab : How do I ensure that the covariance matrix is positive definite when using Kalman Filter
body: <p>For complex valued data, I am finding it hard to ensure that the covariance matrix is positive definite. Taking an example,</p>
  
  <pre><code>P =
  
    10.0000 +10.0000i        0                  0          
          0            10.0000 +10.0000i        0          
          0                  0            10.0000 +10.0000i
  </code></pre>
  
  <p>I can check for positive definiteness of P using the cholesky or the eigenvalues explained below. </p>
  
  <p>(A)  </p>
  
  <pre><code>[R1,p1] = chol(P)
  
  R1 =
  
       []
  
  
  p1 =
  
       1
  </code></pre>
  
  <p>Since p1 > 0, A is not positive definite</p>
  
  <p>(B) Using eigen values : if the eigenvalues are positive, then P should be positive definite. </p>
  
  <pre><code>[r p]=eig(P)
  
  r =
  
       1     0     0
       0     1     0
       0     0     1
  
  
  p =
  
    10.0000 +10.0000i        0                  0          
          0            10.0000 +10.0000i        0          
      0                  0            10.0000 +10.0000i
  </code></pre>
  
  <p>However, doing <code>svd(P)</code> gives all positive eigenalues !!
  Where am I going wrong and what should I do to prevent the P matrix from becoming non positive definite. During run time and real world scenarios it is very hard to ensure the postive definiteness of P. Is there a hack or a way out? Thank you very much</p>