MATLAB
MATLAB
Equations (MAT2002)-MATLAB
Q.1
Find the eigenvalues and eigenvectors of the following matrix:
3 4
A=
4 −3
CODE:
clc
clear
A=input(’Enter the Matrix: ’);
cf=poly(A);
disp(’Characteristic Equations’)
disp(cf)
EV=eig(A);
disp(’Eigenvalues’)
disp(EV) [P D]=eig(A);
disp(’Eigenvectors’)
disp(P)
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB
Exercise
Find the eigenvalues and eigenvectors of the following matrix:
7 −2 2
A = −2 1 4
−2 4 1
Q.2
The product of the eigenvalues of a matrix A is equal to its
determinant.
CODE:
clc;
clear;
A=input(’Enter the Matrix:’);
detA=det(A);
disp(’Determinant of A:’)
disp(detA)
EV=eig(A);
disp(’Eigenvalues:’)
disp(EV)
prev=prod(EV);
disp(’Product of Eigenvalues:’)
disp(prev)
Exercise 2
If λ is an eigenvalues of a matrix A, then λ−1 is the eigenvalue of A−1 .
Hints:
sum(eig(A))
sum(diag(A))