Professional Documents
Culture Documents
Digital Assignment-5: Name: Havila Reddy Register No: 19BCT0211
Digital Assignment-5: Name: Havila Reddy Register No: 19BCT0211
Digital Assignment-5: Name: Havila Reddy Register No: 19BCT0211
Question 1:
Write MATLAB code to solve the system 1 1 2 x ' = 3x − 2x , 2 1 2 x ' = 2x − 2x ; (0) 1 x1
= , x2 (0) = −1
1. Aim of the experiment:
2. Mathematical Procedure:
3. Matlab Code:
clc
clear
syms t A C1 C2
A=input('Enter A: ');
[P,D]=eig(A);
Phi(t)=[P(1,1)*exp(D(1,1)*t) P(1,2)*exp(D(2,2)*t);...
P(2,1)*exp(D(1,1)*t) P(2,2)*exp(D(2,2)*t)];
Xc=Phi(t)*[C1;C2];
disp(Xc)
4. Input:
Output:
(2*5^(1/2)*C1*exp(2*t))/5 + (5^(1/2)*C2*exp(-t))/5
(5^(1/2)*C1*exp(2*t))/5 + (2*5^(1/2)*C2*exp(-t))/5
5. Conclusion:
Question 2:
Write MATLAB code to solve the following difference equation by Z transforms. Solve
y +2 − 5y +1 + 6y = 5 ,n 0 n n n n , 1 y0 = and 1 y1 = .
1. Aim of the experiment:
2. Mathematical Procedure:
3. Matlab Code:
clear all
clc
syms n z
CF=input('Enter the coefficients of Difference equation [a b c]: ');
a=CF(1);b=CF(2);c=CF(3);
f=input('Enter the RHS function in terms of n : ');
Cond=input('Enter the initial conditions [y0 y1]');
y0=Cond(1);y1=Cond(2);
F=ztrans(f);
num=F+(a*z^2+b*z)*y0+a*z*y1;
den=a*z^2+b*z+c;
Y=num/den;
y=iztrans(Y)
m=0:20;
yn=subs(y,n,m);
stem(yn)
title('Difference equation');
xlabel('n'); ylabel('y(n)');
4. Input:
Output:
den =
z^2 - 5*z + 6
y=
(7*2^n)/3 - (3*3^n)/2 + 5^n/6
5. Graph:
6. Conclusion: