Calculating eigenvalue & eigenvectors manually
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone,
I am trying to write a program to find the eigenvalues and eigenvectors of a matrix manually ( without using eig() ).
This is my code here;
[m,n]=size(A);
y=zeros(0);
syms lambda
%Eigenvalue calculation
x=double(solve(det(A-lambda*eye(n)),lambda));
eigenvalues=diag(x);
uniqx=unique(x);
[flag1,flag2]=size(x);
[flag3,flag4]=size(uniqx);
%Eigenvector calculation
for i=1:flag3
B=null(A-uniqx(i)*eye(n));
B=B/norm(B);
y=[y B];
end
eigenvectors=y;
Unfourtunately I am stuck when I try to evaluate the eigenvectors of the corresponding "repeated" eigenvalues. Sometimes it returns me
every eigenvectors corresponds to that repeated value but sometimes it doesn't. I am trying to figure out the properties of the null statement in my code
as I think the problem occurs because of this but still I didn't get the point. (There might be mistakes in my code just critisize me if you see anything stupid :D)
0 comentarios
Respuestas (1)
Esther mensah
el 10 de Oct. de 2019
function [eigenvalues,eigenvectors] = eigen(mat)
syms x
I=eye(size(mat));
eigenvalues=double(solve(det(mat-x*I),x));
for i = 1:length(eigenvalues);
eigenvector= mat-(i)*I;
end
0 comentarios
Ver también
Categorías
Más información sobre Linear Algebra en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!