Different eigenvectors when using eig and null functions
7 次查看(过去 30 天)
显示 更早的评论
Hello,
I'm running a simple script to calculate the eigenvalues and eigenvectors of a given matrix using two different MATLAB functions. The eigenvalues from the two functions are matching. However, the eigenvectors are different. Below is the script:
A = [3 2 ; 7 -1];
syms x;
a2a = sym(A);
polya2a = charpoly(a2a,x);
eigenvalues = solve(polya2a);
eig1 = eigenvalues(1,1);
eig2 = eigenvalues(2,1);
v1 = null(A-eig1*eye(2))
v2 = null(A-eig2*eye(2))
[eig1_m, eig2_m] = eig(A);
v1 and v2 that are using the null function is not matching the eigenvectors obtained from eig function. I appreicate your help. Thanks.
0 个评论
采纳的回答
David Goodmanson
2020-6-8
编辑:David Goodmanson
2020-6-8
Hi Mohammed,
I tossed in some 'double' functions to make the comparison easier
A = [3 2 ; 7 -1];
syms x;
a2a = sym(A);
polya2a = charpoly(a2a,x);
eigenvalues = solve(polya2a);
eig1 = double(eigenvalues(1,1))
v1 = double(null(A-eig1*eye(2)))
eig2 = double(eigenvalues(2,1))
v2 = double(null(A-eig2*eye(2)))
[w, lambda] = eig(A) % rename some stuff
%-----
eig1 = -3.2426
v1 = 0.3051
-0.9523
eig2 = 5.2426
v2 = 0.6656
0.7463
lambda = 5.2426 0
0 -3.2426
w = 0.6656 -0.3051
0.7463 0.9523
Compared to the first way of doing things, the second way has the order of the eigenvalues reversed. So the first column of w, which corresponds to eigenvalue lambda = 5.2426, should be compared to v2. And the second column of w, which corresponds to eigenvalue lambda = -3.2426, should be compared to v1. Both cases agree.
There is no requirement on the overall scaling of eigenvectors and there can be a constant of proportionality between w(:,1) and v2 for example. In that case the constant equals 1, and it's -1 for w(:,2) vs v1.
3 个评论
David Goodmanson
2020-6-8
Hi Mohammed,
I don't know what to say, because I just copied the code back into the editor and it works fine. I'm using 2019b. And the v1 and v2 calculations are your expressions preceded by 'double'. What do you get without using double?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Algebra 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!