Application of Differential and Difference
Equations (MAT2002)-MATLAB
Dr. Amit Sharma
Vellore Institute of Technology, Vellore
December 12, 2019
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB
Matrix Formation
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB
Matrix Operations
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB
Matrix Operations
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB
Transcendental Functions
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB
Code
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
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB
Code
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)
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB
Exercise 1
The sum of the eigenvalues of a matrix is the sum of the elements of
the principal diagonal.
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))
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB
Exercise: Find the eigenvalues of a matrix without using "eig"
command.
Hint:
charpoly(A, x)
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB
Plotting
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB
Plotting
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB
Plotting
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB
Plotting
Dr. Amit Sharma Application of Differential and Difference Equations (MAT2002)-MATLAB