Calculating eigenvalue & eigenvectors manually
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Esther mensah
le 10 Oct 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 commentaires
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!