Ex 3

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

The z-transform of a sequence x(n) is given by

where z is a complex variable. The set of z values for which X(z) exists is called the region of
convergence (ROC) and is given by Rx−< |z| < Rx+ for some non-negative numbers Rx− and
Rx+.
The inverse z-transform of a complex function X(z) is given by

where C is a counterclockwise contour encircling the origin and lying in the ROC.

Aim: To understand the Z-transform operations and solve the differential equations.

1. Let X1(z) = 2 + 3z−1 + 4z−2 and X2(z) = 3 + 4z−1 + 5z−2 + 6z−3. Determine X3(z) =
X1(z)X2(z).
2. num1 = [ 2 3 4 ]; % Numerator: s
3. den1 = [ 1 0 0 ]; % Denominator: s^2 + 2 s + 10
4. H = tf(num1,den1);
5. num2 = [ 3 4 5 6]; % Numerator: s
6. den2 = [ 1 0 0 0]; % Denominator: s^2 + 2 s + 10
7. I = tf(den2,num2);
8. V = 3*H*I;

2. Determine the inverse z-transform of

so that the resulting sequence is causal and contains no complex numbers.


t = 1 : pi/180 : pi;
syms z
tf_1 = 2*z^2+3*z+4/z^2;
tf_2 = 3*z^3+4*z^2+5*z+6/z^3;
tf_3 = tf_1*tf_2;
tf_4 = iztrans(tf_2);
tf_5 = iztrans(tf_3);
tf_6 = iztrans(tf_1);
tf_7 = tf_4*tf_6;
k = iztrans(tf_7);
if t>0
('signal is causal')
else
('signal is non causal')
end

3. Given a causal system


y(n) = 0.9y(n − 1) + x(n)
a. Determine H(z) and sketch its pole-zero plot.
b. Plot |H(ejω)| and H(ejω).
c. Determine the impulse response h(n).
4. clearvars; clc; close all;
5.
6. % u(t) : 0 for n<0 and 1 for n>=0
7. oldparam = sympref('HeavisideAtOrigin',1);
8.
9. syms n z
10. assume(n, 'integer');
11.
12. %%time series
13. x(n)=((0.9)*n)*heaviside(1-n);
14.
15. % break into two time series
16. x1(n)=( (0.9)*n )* heaviside(-n);
17. x2(n)=( (0.9)*n )* (heaviside(n-1)-heaviside(n-2));
18.
19. % plot time series
20. ntest=-8:1:8;
21.
22. subplot(2,1,1); stem(ntest, x(ntest), 'b^');
23. title(texlabel(x(n))); xlabel('n'), ylabel('x(n)');
24.
25. subplot(2,1,2); stem(ntest, x1(ntest), 'ro'); hold on;
26. subplot(2,1,2); stem(ntest, x2(ntest), 'g*','Color', [0 .5 0]);
27. legend('x1', 'x2'); title('decomposition to x1(n), x2(n)');
28.
29. %%z-transform of x1(n)
30.
31. % create "time reversed" version
32. x1r(n)=subs(x1(n),n,-n);
33.
34. % z-transform of x1r(n)
35. X1r(z)=simplifyFraction( ztrans(x1r(n),n,z) );
36.
37. % z-transform of x1(n)
38. X1(z)=simplifyFraction( subs(X1r(z),z,z^-1) );
39.
40. %%z-transform of x2(n)
41. X2(z)=simplifyFraction( ztrans(x2(n)) );
42.
43. %%calculation of z-transform of x(n)
44.
45. X(z)=X1(z)+X2(z);

H = tf([0 -180 90],[100 -200 0 100]);


pzmap(H)
bode(H)
clc;
clear all;
close all;
N1 = 50;
num1 = [0 -180 90];
den1 = [100 -200 0 100];
y1 = impz (num1, den1, N1);
n2 = 0 : N1-1;
stem(n2, y1);
H = tf([0 180 90],[100 -200 0 200]);
num1 = [ 0 180 90 ]; % Numerator: s
den1 = [ 100 -200 200 ]; % Denominator: s^2 + 2 s + 10
H = tf(num1,den1);

pzmap(H)
bode(H)
% MATLAB CODE (WITH INITIAL CONDITIONS):
% To clear all variables from the current workspace
clear all
clc
disp("Solving 2nd Order Homogeneous Difference Equations in MATLAB |
GeeksforGeeks")

% To Declare them as Variables


syms r c1 c2 n
F=input('Input the coefficients [a,b,c]: ');

% Coefficients of the 2nd Order Difference Equation


a=F(1);b=F(2);c=F(3);

% Auxiliary Equation Formed


eq=a*(r^2)+b*(r)+c;
S=solve(eq);

% Roots of the Auxiliary Equation Formed


r1=S(1);r2=S(2);

% Determinant of the Auxiliary Equation Formed


D=b^2-4*a*c;
if D>0
y1=(r1)^n;
y2=(r2)^n;
yn=c1*y1+c2*y2;
elseif D==0
y1=(r1)^n;
y2=n*((r2)^n);
yn=c1*y1+c2*y2;
else
P=abs(r1);
t=angle(r1);
y1=((P)^n)*cos(n*t);
y2=((P)^n)*sin(n*t);
yn=c1*y1+c2*y2;
end
IC=input('Enter the initial conditions in the form [y0,y1]:');

% Initial conditions
y0=IC(1);y1=IC(2);
eq1=subs(yn,n,0)-y0;
eq2=subs(yn,n,1)-y1;

% Finding C1 & C2
[c1,c2]=solve(eq1,eq2);
yn=simplify(subs(yn));
disp ('The solution of the difference equation yn=')
disp(yn)

You might also like