Lab Sheet 3
Lab Sheet 3
Report On
Labe 3 Poles and Zeros
1
Source Code
% lab 3 qno 1
b = [1 3 5];
a = [1 -0.5 0.8];
w = linspace(0,pi,10);
num = b(1) + b(2)*exp(-1i*w) + b(3)*exp(-1i*w*2);
den = a(1) + a(2)*exp(-1i*w) + a(3)*exp(-1i*w*2);
h = num./den;
subplot(211);
plot(w,abs(h),'*-');
subplot(212);
plot(w,phase(h),'*-');
title('CRN 017 311');
% or we can use
freqz(b,a);
Output:
1
2.Write a MATLAB program that calculates the poles and zeros of this digital
filter. Also plot the polesand zeros of this filter. Hint use the tf2zp & zplane
MATLAB command.
% lab 3 qno 2
clc; clear all;
b = [1 3 5];
a = [1 -0.5 0.8];
[z,p,k] = tf2zp(b,a)
"CRN 017-311"
Output:
Source Code:
% lab 3 qno 2
clc; clear all;
b = [1 3 5];
a = [1 -0.5 0.8];
zplane(b,a)
2
Output:
Source Code:
% lab 3 qno 3
clc; clear all;
3
z = [+1 -1 1+1i 1-1i].';
p = [0.5 -0.5 0.1+2i 0.1-2i].';
k = 1;
[b,a] = zp2tf(z,p,k)
"CRN 017-311"
Output:
4. Write a MATLAB program that plots the poles and zeros of the digital filter in
step 3.
Source Code:
% lab 3 qno 4
clc; clear all;
z = [+1 -1 1+1i 1-1i].';
p = [0.5 -0.5 0.1+2i 0.1-2i].';
k = 1;
[b,a] = zp2tf(z,p,k)
zplane(b,a)
"CRN 017-311"
Output:
4
5. Write a MATLAB program that calculates the poles and zeros of the
accumulator circuit whosedifference equation is1]-y[n][ y[n]nx.
Source Code:
% lab 3 q 5
clear; close all;
A = [1,-1]; % Coefficient of y[n]
B = 1; % Coefficient of x[n]
[z,p,k] = tf2zp(B,A)
zplane(z,p,k)
Output:
5
6. Write a MATLAB program that factorised the 4th order digital filter in step
3 into two cascaded 2ndorder digital filters.Hint use the zp2sos MATLAB
command.
6
Source Code:
% lab 3 qno 6
clc; clear all;
z = [+1 -1 1+1i 1-1i].';
p = [0.5 -0.5 0.1+2i 0.1-2i].';
k = 1;
[sos,g] = zp2sos(z,p,k)
"CRN 017-311"
Output:
Source Code:
% lab 3 qno 7
clc; clear all;
z = [+1 -1 1+1i 1-1i].';
p = [0.5 -0.5 0.1+2i 0.1-2i].';
k = 1;
[b,a] = zp2tf(z,p,k)
[r,p,x] = residuez(b,a)
"CRN 017-311"
7
Output:
8
8.Write a MATLAB program that calculates the partial fraction expansion of
system function obtainedin question no. 6. Hint use residuez MATLAB command.
Source Code:
% lab 3 qno 7
clc; clear all;
z = [+1 -1 1+1i 1-1i].';
p = [0.5 -0.5 0.1+2i 0.1-2i].';
k = 1;
[b,a] = zp2tf(z,p,k)
[r,p,x] = residuez(b,a)
"CRN 017-311"
Output:
9
10
11