Different eigenvectors when using eig and null functions
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohammed Raslan
am 8 Jun. 2020
Kommentiert: Mohammed Raslan
am 9 Jun. 2020
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 Kommentare
Akzeptierte Antwort
David Goodmanson
am 8 Jun. 2020
Bearbeitet: David Goodmanson
am 8 Jun. 2020
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 Kommentare
David Goodmanson
am 8 Jun. 2020
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?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Linear Algebra finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!