02.10.2019 Views

UploadFile_6417

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Quantization of Filter Coefficients 281<br />

One can perform analysis similar to that for the movement of poles to<br />

obtain maximum change in the magnitude or phase responses due to<br />

changes in filter coefficients. However, such an analysis is very complicated<br />

and may not add any new insight. Hence we will study these effects using<br />

MATLAB. We provide the following two examples.<br />

□ EXAMPLE 6.27 Compute and plot magnitude responses of filter structures given for the filter<br />

in Example 6.26.<br />

Solution<br />

The filter is a bandpass filter with 10 tightly clustered poles implemented using<br />

the direct and the cascade forms. For the direct-form structure, we compute the<br />

magnitude response for infinite precision as well as for 16-bit quantization. For<br />

the cascade-form structure, we use 16-bit and 11-bit representations.<br />

r = 0.9; theta = (pi/180)*[-55:5:-35,35:5:55]’;<br />

p = r*exp(j*theta); a = poly(p); b = 1;<br />

w = [0:500]*pi/500; H = freqz(b*1e-4,a,w);<br />

magH = abs(H); magHdb = 20*log10(magH);<br />

% Direct form: quantized coefficients<br />

N = 15; [ahat,L,B] = Qcoeff(a,N);<br />

TITLE = sprintf(’%i-bit (1+%i+%i) Precision (DF)’,N+1,L,B);<br />

Hhat = freqz(b*1e-4,ahat,w); magHhat = abs(Hhat);<br />

% Cascade form: quantized coefficients: Same N<br />

[b0,B0,A0] = dir2cas(b,a);<br />

[BAhat1,L1,B1] = Qcoeff([B0,A0],N);<br />

TITLE1 = sprintf(’%i-bit (1+%i+%i) Precision (CF)’,N+1,L1,B1);<br />

Bhat1 = BAhat1(:,1:3); Ahat1 = BAhat1(:,4:6);<br />

[bhat1,ahat1] = cas2dir(b0,Bhat1,Ahat1);<br />

Hhat1 = freqz(b*1e-4,ahat1,w); magHhat1 = abs(Hhat1);<br />

% Cascade form: quantized coefficients: Same B (N=L1+B)<br />

N1 = L1+B; [BAhat2,L2,B2] = Qcoeff([B0,A0],N1);<br />

TITLE2 = sprintf(’%i-bit (1+%i+%i) Precision (CF)’,N1+1,L2,B2);<br />

Bhat2 = BAhat2(:,1:3); Ahat2 = BAhat2(:,4:6);<br />

[bhat2,ahat2] = cas2dir(b0,Bhat2,Ahat2);<br />

Hhat2 = freqz(b*1e-4,ahat2,w); magHhat2 = abs(Hhat2);<br />

% Comparison of Magnitude Plots<br />

Hf_1 = figure(’paperunits’,’inches’,’paperposition’,[0,0,6,4]);<br />

subplot(2,2,1); plot(w/pi,magH,’g’,’linewidth’,2); axis([0,1,0,0.7]);<br />

%xlabel(’Digital Frequency in \pi units’,’fontsize’,10);<br />

ylabel(’Magnitude Response’,’fontsize’,10);<br />

title(’Infinite Precision (DF)’,’fontsize’,10,’fontweight’,’bold’);<br />

subplot(2,2,2); plot(w/pi,magHhat,’r’,’linewidth’,2); axis([0,1,0,0.7]);<br />

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).<br />

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!