How to Check Positive Definites in MATLAB
- 1). Define a matrix in the usual manner with MATLAB. For example, "A = [1 2; 3 4]" will produce:
A =
1 2
3 4 - 2). Type "EIG(A)" and hit "Enter." MATLAB produces all the eigenvalues of the matrix. For the matrix defined in the previous step, MATLAB outputs:
ans =
-0.3723
5.3723 - 3). Inspect the output. Only if all values are positive is the matrix positive definite. The matrix in the previous step is not positive definite.
- 1). Define a matrix in the usual manner with MATLAB. For example, "A = [1 2; 3 4]" will produce:
A =
1 2
3 4 - 2). Type "[R,p] = chol(A)". For matrix "A" in the previous step, MATLAB outputs the following:
R = 1
p = 2 - 3). Inspect the result -- specifically, the value of "p". Only if "p" is zero is the matrix positive definite. Matrix "A" in the previous step is not positive definite.
Check with EIG
Check with CHOL
Source...