100% found this document useful (1 vote)
114 views4 pages

Lab Da 1

The document discusses solving three problems related to matrix operations in MATLAB. Problem 1 verifies the Cayley-Hamilton theorem for a matrix and finds its inverse. Problem 2 diagonalizes a matrix using similarity transformations. Problem 3 diagonalizes a symmetric matrix by finding an orthogonal matrix.

Uploaded by

Rajat Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
114 views4 pages

Lab Da 1

The document discusses solving three problems related to matrix operations in MATLAB. Problem 1 verifies the Cayley-Hamilton theorem for a matrix and finds its inverse. Problem 2 diagonalizes a matrix using similarity transformations. Problem 3 diagonalizes a symmetric matrix by finding an orthogonal matrix.

Uploaded by

Rajat Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Fall Semester 2019-20. Solution of Digital Lab Assignment-1 (MAT 2002).

Registration Number: 18BME0743 Name of Student: RAJAT MISHRA

Problem1: Input a matrix A, verify Cayley Hamilton theoreom and hence


find the inverse of A .(Check whether inverse exists or not.)
clc
clear all
A=input('Enter the Matrix:');
cf=poly(A);
n=length(cf);
CHT=cf(1)*A^(n-1);
for i=2:n
CHT=CHT+cf(i)*A^(n-i);
end
disp('R.H.S of C-H Theorem:')
disp(round(CHT))
D=det(A);
if(D==0)
disp('inverse doesnot exist');
end
disp('inverse exists');
INV=cf(1)*A.^(n-2);
for i=2:n-1
INV=INV+cf(i)*A.^(n-i-1);
end
INV=INV/(-cf(n));
disp('Inverse of A:')
disp(INV)

MATLAB OUTPUT:
Enter the Matrix:[1 4;2 3]
R.H.S of C-H Theorem:
0 0
0 0
inverse exists
Inverse of A:
-0.6000 0
-0.4000 -0.2000
Problem 2: Diagonalize a matrix A by similarity transformation
and hence find 𝐴 𝑛 (n=9).

clc
clear all
A=input('Enter the matrix for diagonalization :');
[P D]=eig(A);
disp('Given Matrix (A) :')
disp(A)
disp('Modal Matrix (P):')
disp(P)
disp('Inverse of P :')
PI=inv(P);
disp(PI)
disp('Diagonal Matrix (D=Pˆ(-1)*A*P):')
DM=round(inv(P)*A*P, 2);
disp(DM)
n=input('enter the power:');
Apown=P*(DM.^n)*inv(P);
disp(Apown)

MATLAB OUTPUT:
Enter the matrix for diagonalization :[2 2 -7; 2 1 2; 0 1 -3]

Given Matrix (A) :

2 2 -7

2 1 2

0 1 -3

Modal Matrix (P):

-0.6350 0.2357 0.7276

-0.7620 -0.9428 -0.4851

-0.1270 -0.2357 0.4851

Inverse of P :

-1.1249 -0.5624 1.1249

0.8485 -0.4243 -1.6971

0.1178 -0.3534 1.5314


Diagonal Matrix (D=Pˆ(-1)*A*P):

3 0 0

0 1 0

0 0 -4

enter the power:9

1.0e+05 *

-0.0841 0.7444 -3.0616

0.3185 -0.3650 1.7787

-0.1217 0.4634 -1.9755

Problem 3: Diagonalize a symmetric matrix A by finding an orthogonal


matrix P and hence find 𝐴 𝑛 (n=8).

clc
clear all
A=input('Enter the symmetric matrix for diagonalisation:');
[P D]=eig(A);
disp('Given Matrix (A) :')
disp(A)
disp('Modal Matrix (P) :')
disp(P)
NP=normc(P);
disp('Normalized Modal Matrix (N):')
disp(NP)
disp('Diagonal Matrix (D=N^T*A*N):')
DM=round(NP'*A*NP,2);
disp(DM)
n=input('enter the power:');
Apown=NP*(DM.^n)*inv(NP);
disp(Apown)

MATLAB OUTPUT:
MATLAB OUTPUT:
Enter the symmetric matrix for diagonalisation:[1 -1 3; -1 5 6;
3 6 7]
Given Matrix (A) :
1 -1 3
-1 5 6
3 6 7
Modal Matrix (P) :
0.6450 0.7492 0.1510
0.5331 -0.5826 0.6135
-0.5476 0.3152 0.7751
Normalized Modal Matrix (N):
0.6450 0.7492 0.1510
0.5331 -0.5826 0.6135
-0.5476 0.3152 0.7751
Diagonal Matrix (D=N^T*A*N):
-2.3700 0 0
0 3.0400 0
0 0 12.3300
enter the power:8
1.0e+08 *
0.1219 0.4950 0.6254
0.4950 2.0109 2.5403
0.6254 2.5403 3.2093

You might also like