a Choose the frequency band of interest between 0,1π and 0,9π.. Plot the impulse response and the amplitude response.. Compare the result with the theoretical “derivative” of x n.. Note
Trang 1ĐẠI HỌC ĐÀ NẴNG TRƯỜNG ĐẠI HỌC BÁCH KHOA
KHOA ĐIỆN TỬ VIỄN THÔNG
-o0o -BÀI TẬP MÔN Thiết kế lọc số và mã hóa băng con
Lớp: K25.KĐT.ĐN
Đà Nẵng, 12/2012
Trang 2Problem 6.9
A linear time-invariant system is given by the system function
H ( z)= ∑
k=0
10
(2 z )-k
Determine and draw the block diagrams of following structures
a) Direct form
b) Cascade form
Solution:
a)
Bộ lọc FIR được mô tả bởi hàm hệ thống:
H ( z)= ∑
k=0
10
(2 z )-k
Script MATLAB:
Clear; close all;
%% Direct form %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
Disp(‘*** Direct Form Coefficients ***’)
*** Direct Form Coefficients ***
K = 0:10; b = (0.5).^k, a = 1;
B =
Columns 1 through 7
1.0000 0.5000 0.2500 0.1250 0.0625 0.0625 0.0312 0.0156
Columns 8 through 11
0.0078 0.0039 0.0020 0.0010
Trang 3Script MATLAB
%% Cascade Form: %%%%%%%%%%%%%%%%%%%%%%%%%% disp (‘*** Cascade Form Coefficients ***’)
[b0, B, A] = dir2cas (b,a)
B0 =
1
B = 1.0000 0.9595 0.2500 1.0000 0.6549 0.2500 1.0000 0.1423 0.2500 1.0000 - 0.4154 0.2500 1.0000 - 0.8413 0.2500 A = 1 0 0
1 0 0
1 0 0
1 0 0
Trang 41 0 0
Problem 7.20:
Using the Parks-McClellan algorithm, design a 25-tap FIR differentiator with slope equal to 1 sample/cycle.
a) Choose the frequency band of interest between 0,1π and 0,9π Plot the impulse π Plot the impulse response and the amplitude response.
b) Generate 100 samples of the sinusoid
x(n) = 3sin(0,25πn), n = 0, … , 100 and process through the above FIR diffentiator Compare the result with the
theoretical “derivative” of x (n) Note: don’t forget to take the 12-sample delay of the FIR filter into account.
Solution:
a)
clear; close all;
% Specifications
M = 25; w1 = 0.1*pi; w2 = 0.9*pi; % slope = 1 sam/cycle
%
% (a) Design
f = [w1/pi w2/pi]; m = [w1/(2*pi) w2/(2*pi)];
[db, mag, pha, grd, w] = freqz_m(h,1);
Hf_1 = figure('Units','normalized','position',[0.1,0.1,0.8,0.8],'color',
[0,0,0]);
set(Hf_1,'NumberTitle','off','Name','P7.20.a');
Trang 5subplot(2,1,1);stem([0:1:M-1],h);title('Impulse Reponse'); axis([-1,25,-0.2,.2]);
xlabel('n','fontsize',10); ylabel('h(n)','fontsize',10);
set(gca,'XTickMode','manual','XTick',[0;12;24],'fontsize',10);
subplot(2,1,2);plot(w/(2*pi),mag);title('Magnitude Response');grid; axis([0,0.5,0,0.5]);
xlabel('Normalized frequency in cycles/sam','fontsize',10)
set(gca,'XTickMode','manual','XTick',[0;w1/(2*pi);w2/
(2*pi);0.5],'fontsize',10);
set(gca,'XTickMode','manual','YTick',[0;0.5;0.45;0.5],'fontsize',10);
Trang 6% (b) Differentiator verification
Hf_2 = figure('Units','normalized','position',[0.1,0.1,0.8,0.8],'color',
[0,0,0]);
set(Hf_2,NumberTitle','off','Name','P7.20b');
[Hr,w,P,L] = ampl_res(h); subplot; plot(w/(2*pi), Hr);
*** Type-3 Linear-Phase Filter ***
title('Amplitude Response'); grid; axis([0,0.5,-0.5,0]);
set(gca,'XTickMode','manual','XTick',[0;w1/(2*pi);w2/
(2*pi);0.5],'fontsize',10);
set(gca,'YTickMode','manual','YTick',[-0.5;-0.45;-0.05;0],'fontsize',10);
Đáp ứng biên độ được biểu diễn như hình trên Dấu của h(n) là âm, do đó chúng ta sẽ chập x(n) với –h(n) và sẽ so sánh đầu vào với đầu ra ở trạng thái tăng dần (ví dụ khi n
> 25) với đầu ra được dịch 12 mẫu về bên trái là pha trễ của của bộ vi phân.
Hf_3 = figure('Units','normalized','position',[0.1,0.1,0.8,0.8],'color',
[0,0,0]);
Trang 7n=[0:1:100]; x = 3*sin(0.25*pi*n); y = conv(x,-h);
m = [41:1:81];
plot(m,x(41:1:81),m,y(41+12:1:81+12));grid % add 12 sample delay to y
xlabel('n'); title('Input-Output Sequences'); axis([40,82,-4,4]);
set(gca,'XTickMode','manual','XTick',[41;81],'fontsize',10);
set(gca,'YTickMode','manual','YTick',[-3;0;3],'fontsize',10);
Đồ thị đầu ra và đầu vào được biểu diễn ở hình trên Vì độ dốc là π/2 sam/rad, độ lợi tại ω = 0,25π bằng 0,125 Vì vậy, đầu ra (khi dịch) là:
y(n) = 3.(0,125)cos(0,25πn) = 0,375cos(0,25πn)