MATLAB Help - Computing Eigenvalues and Eigenvectors without the eig() function

preview_player
Показать описание
Thanks to Jasmeet Singh for giving me the idea to make this video!! You can check out his channel here

Ever wanted to find the eigenvalues and eigenvectors without the eig function? Well if you have charpoly() and rref() you can still do it.
Рекомендации по теме
Комментарии
Автор

Thank you for this. I was beating my head against this problem for hours before I started searching for - and found - your video. Cheers!

coffeeforallbutespeciallyme
Автор

Even complex matrices like A = [2 complex(0, -1) complex(0, 2);complex(0, 1) 4 3;complex(0, -2) 3 5] will work.

CarlosMontalvo
Автор

Could you clarify if the method you implemented is based on the QR algorithm, the Rayleigh quotient iteration, or something else?

ofloresvazquez
Автор

What about a 5x5 matrix how would you adjust the code to calculate the eigenvectors

markusroyik-turner
Автор

Thank you for the video sir.

I tried it for a 3by3 matrix and it worked in all cases. However, when I tried it with a 4by4, I got values that were not in agreement with the results I expected. What could be the reason sir?

Thank you.

P.S: They results I checked it against were from MuPAD app on MATLAB 2016.

beebee_
Автор

Im trying it for a 5x5 matrix but my code isn't giving me the right answer:

A = [5 4 3 2 1; 4 5 4 3 2; 3 4 5 4 3; 2 3 4 5 4; 1 2 3 4 5]
N = 5

% Find the eigenvalues

char_eqn = charpoly(A);

eigenvalues = roots(char_eqn);

s_without_eig = diag(eigenvalues)

%% Find the eigenvectors

% A * V = S * V

v_without_eig = zeros(N, N)

for idx = 1, N;
si = eigenvalues(idx)
Atilde = (A - si * eye(N))
Atilde_red = rref(Atilde)

%det(Atilde)

% vi = zeros(N, 1)

vi(end) = 1;
vi = [-Atilde_red(1:(N-1), N);1]

%Since Matlab normalizes vectors:
vi = vi/norm(vi);
v_without_eig(:, idx) = vi
end

v_without_eig

wesleycottrill
Автор

Is it possible to find an expression to find eigenvalues in terms of trace() and det()?

playerunknown
Автор

The video was very helpful but when I try 5×5 matrix I don't get the correct eigenvector

night-knight
Автор

Can you test this matrix [ 1 3 4; 3 -1 2; 4 2 2], sir, I think it gets some bugs when finding eigenvectors.

khanhnguyennhut
Автор

Its video very useful for me. But sir why i cant use charpoly even though my matlab is 2010?

nandashabrina
Автор

Use the code in the video. Got the same result, but for antoher example the answer was unexpectable. For A = [5 6 3, -1 0 1, 1 2 -1] I got v_withoug_eig = [0 0 0, -0.4472 0 -0.7071, 0.8944 1 0.7071]. But the true answer is [0 2 9, 1 -1 -2, -2 0 1]

There you can see my code.
Thank you in advance!

%%% Находим собственные значения
A = [5 6 3;-1 0 1; 1 2 -1]

N = 3;
[v, s] = eig(A)
char_eqn = charpoly(A)
eigenvalues = roots(char_eqn);

s_without_eig = diag(eigenvalues)

%%% Находим собственные векторы'
v_without_eig = zeros(N, N);
for idx = 1:N
si = eigenvalues(idx);
Atilde = (A - si * eye(N));
det(Atilde);
Atilde_red = rref(Atilde);

%%%vi = zeros(N, 1)

vi = [-Atilde_red(1:(N-1), N); 1];

vi = vi/norm(vi);

v_without_eig(:, idx) = vi;
end

v_without_eig

stepanov_dmtrii
Автор

Question if your given these functions for the for loop to find eigenvectors for matlab such as: null, eye and norm how would that code change please reply back

bobjohns
welcome to shbcf.ru