Uploaded by Roman Arredondo

LabPDSTR Telecomunicaciones 2022 I Manual Lab Mitra

advertisement
140
Chapter 8 • Digital Filter Implementation
Gray-Markel cascaded lattice realization. Simulate and verify the realization using Program
P8 2.
Project 8.2
Illustration of Filtering
Program P8 3 illustrates the design of a causal IIR filter, its simulation in transposed Direct
Form II, and its application in filtering a signal.
% Program P8_3
% Illustration of Filtering by an IIR Filter
%
clf;
% Generate the input sequence
k = 0:50;
w2 = 0.7*pi;w1 = 0.2*pi;
x1 = 1.5*cos(w1*k); x2 = 2*cos(w2*k);
x = x1+x2;
% Determine the filter transfer function
[N, Wn] = ellipord(0.25, 0.55, 0.5, 50);
[num, den] = ellip(N,0.5, 50,Wn);
% Generate the output sequence
y = filter(num,den,x);
% Plot the input and the output sequences
subplot(2,1,1);
stem(k,x); axis([0 50 -4 4]);
xlabel(’Time index n’); ylabel(’Amplitude’);
title(’Input Sequence’);
subplot(2,1,2);
stem(k,y); axis([0 50 -4 4]);
xlabel(’Time index n’); ylabel(’Amplitude’);
title(’Output Sequence’);
Questions:
Q8.9 What type of filter is being designed by Program P8 3? What are its specifications?
What is the order of the filter? What are the frequencies of the sinusoidal sequences forming
the input?
Q8.10 Run Program P8 3 and generate the two plots. Which component of the input
appears at the filter output? Why is the beginning part of the output sequence not a perfect
sinusoid? Modify Program P8 3 to filter the sequence x2[n] only. Is the output generated
as expected? Justify your answers.
The cascade form of an IIR transfer function can be generated from its zero-pole description
using the function zp2sos. The code fragment given below illustrates the generation of
8.5 Simulation of FIR Digital Filters
141
the transfer functions of each section of the elliptic lowpass transfer function example
of Program P8 3 and its implementation in cascade form along with the overall transfer
function as one section with all realizations in Direct Form II.
[N, Wn] = ellipord(0.25, 0.55, 0.5, 50);
[num,den] = ellip(N,0.5, 50,Wn);
[z,p,const] = tf2zp(num,den);
sos = zp2sos(z,p,const);
row1 = real(sos(1,:));row2 = real(sos(2,:));
num1 = row1(1:3);den1 = row1(4:6);
num2 = row2(1:3);den2 = row2(4:6);
y = direct2(num,den,x);
y1 = direct2(num1,den1,x);y2 = direct2(num2,den2,y1);
Questions:
Q8.11 Using the above code fragment modify Program P8 3 to filter the sequence being
generated by a cascade structure and compare the output generated with the output generated
when filtered by a single higher-order section. Is there any difference between the two
outputs? Show precisely the two filters being simulated by writing down the expression for
the transfer function of each simulation.
Q8.12 Using the function strucver modify the program developed in Question Q8.11
to verify the structure being simulated. Run the modified program. Are your simulations
correct?
A long input sequence can be filtered using the overlap-add method in which the input
sequence is segmented into a set of contiguous short input blocks, each block is then
filtered separately, and the overlaps in the output blocks are added appropriately to generate
the long output sequence. This method of filtering can be implemented easily on MATLAB
using the second form of the function filter. Here the final values of the state variable
vector sf at any stage of filtering are fed back in the following stage of filtering as the initial
condition vector si.
Question:
Q8.13 Modify Program P8 3 by filtering the input sequence into a set of contiguous blocks
of length 5 each. Run the modified program and compare your result with that generated
by filtering the input as one segment.
8.5
Simulation of FIR Digital Filters
The functions direct2 and filter can also be used to implement an FIR digital filter as
illustrated in this project.
Download