A serious problem when calculating eigenvectors of a matrix with the function eig
이전 댓글 표시
Hi all,
I calculated the eigenvalues of A=[1 2;3 4] as [vec,val]=eig(A) and I found:vec=[-0.8246 -0.4160;0.5658 -0.9094] and val=[-0.3723 0;0 5.3723].
With Mathematica and Maple, the eigenvalues of A are the same as Matlab, but vec=[0.45743 1.0000;-1.4574 1.0000] (the same in maple and mathematica) is totaly different than Matlab.
It is a serious problem.
Thank you
답변 (1개)
Sebastian Castro
2015년 8월 17일
The results are actually the same, but (not knowing anything about Maple and Mathematica) the formatting is different. It looks like
- The MATLAB vectors are normalized while the Maple/Mathematica ones aren't -- instead, they have one element with a value of 1.0 and the other one is relative to that.
- The MATLAB vectors are expressed in columns while the Maple/Mathematica are in rows.
To test this out, I did the following:
>> v1_maple = [0.45743 1];
>> v1_maple/norm(v1_maple)
ans =
0.4160 0.9094
>> v2_maple = [-1.4575 1];
>> v2_maple/norm(v2_maple)
ans =
-0.8246 0.5657
Compare those results with the columns of the MATLAB results and there you go! Well, one says 0.5657 and the other says 0.5658, but that might be a display/rounding issue.
- Sebastian
댓글 수: 4
Boughrara kamel
2015년 8월 17일
Sebastian Castro
2015년 8월 17일
If you really want them to not be normalized, then just divide them by the element you'd like to set to 1. For example,
>> V = [-0.8246; 0.5658];
>> V/V(2)
ans =
-1.4574
1.0000
- Sebastian
Greg Obi
2020년 3월 11일
hey can you expound more on how you can get the results to be unormalized. I'm having the same issue and I'm getting closer to understanding it.
Steven Lord
2020년 3월 11일
By the definition, if V is an eigenvector of a matrix A with eigenvalue d, then A*V = V*d.
Now let's consider a new vector W = 2*V. Is W an eigenvector of A, and if so what's its eigenvalue?
A*W = A*2*V % Since W = 2*V
A*2*V = 2*A*V % Since scalars commute with matrices
2*A*V = 2*V*d % Since V is an eigenvector of A with eigenvalue d
2*V*d = W*d % Since 2*V = W
Therefore A*W = W*d. That means W is also an eigenvector of A and it has the same eigenvalue d as V does.
You can generalize this argument to any non-zero multiple of the eigenvector.
A = rand(5);
[V, D] = eig(A);
v1 = V(:, 1);
d1 = D(1, 1);
% v1 is an eigenvector of A with eigenvalue d1
shouldBeSmall1 = A*v1-v1*d1
% So is pi*v1
shouldBeSmall2 = A*(pi*v1)-(pi*v1)*d1
% We don't need to restrict ourselves to real number either
% (3+4i)*v1 is an eigevector as well
c1 = (3+4i)*v1;
shouldBeSmall3 = A*c1-c1*d1
In Sebastian's example, the chosen non-zero multiplier was (1/V(2)). You can choose a different multiplier if it's appropriate for the physical application the matrices whose eigenvalues you're computing are modeling.
카테고리
도움말 센터 및 File Exchange에서 App Building에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!