Error while Diagonalizing the Matrix
조회 수: 3 (최근 30일)
이전 댓글 표시
I'm studying State Space function thesedays, and made a code below
A = [ 0 1 0; 0 0 1; -6 -11 -6];
P = [ 1 1 1; -1 -2 -3; 1 4 9 ];
S = P^(-1);
A1 = S*A*P;
Expected answer was
A1 = [ -1 0 0 ; 0 -2 0 ; 0 0 -3 ]
because of the eigenvalue process, however, it made a conclusion as
A1 = [ -1, -1.7764e-15, -2.6645e-15 ; 2.6645e-15, -2, 7.1054e-15 ; -1.3323e-15, -2.6645e-15, -3 ]
And other variables are calculated just as I expected.
I don't know what makes this kind of error and how can I solve it?
It can be a critical error in the process.
답변 (1개)
Walter Roberson
2020년 7월 4일
Do not use P^(-1), which is also known as inv(P), if you can avoid doing so. The calculations have too much numeric difficulty.
Use the \ or / operator insted.
A1 = P\A*P
The answer will not be the exact integers you are expecting, but it will be closer to what you are expecting.
If you need exact values then do not work numerically, work symbolically:
A1 = P\sym(A)*P
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Eigenvalues & Eigenvectors에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!