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.

510 Chapter 9 SAMPLING RATE CONVERSION<br />

ylabel(’Amplitude’,’vertical’,’cap’);<br />

title(’Amplitude Response’,’fontsize’,TF,’vertical’,’baseline’);<br />

xlabel(’Frequency in \pi units’,’vertical’,’middle’);<br />

subplot(2,2,2); plot(w/pi,Hdb,’m’,’linewidth’,1.0); axis([0,1,-50,10]);<br />

set(gca,’xtick’,[0,wp/pi,ws/pi,1],’ytick’,[-50,round(min_attn),0]); grid<br />

ylabel(’Decibels’,’vertical’,’cap’);<br />

xlabel(’Frequency in \pi units’,’vertical’,’middle’);<br />

title(’Log-magnitude Response’,’fontsize’,TF,’vertical’,’baseline’);<br />

subplot(2,2,4);<br />

lw = length(w)-1; PB = [0:floor(wp/pi*lw)]; HrPB = Hr(PB+1)-1;<br />

SB = [ceil(ws/pi*lw):lw]; HrSB = Hr(SB+1);<br />

[AX,H1,H2] = plotyy(PB/lw,HrPB,SB/lw,HrSB);<br />

delta1 = round(delta1*1000)/1000; delta2 = round(delta2*100)/100;<br />

set(AX(1),’xtick’,[0,wp/pi,ws/pi,1],’ytick’,[-delta1,0,delta1],’Ycolor’,’g’);<br />

set(AX(2),’xtick’,[0,wp/pi,ws/pi,1],’ytick’,[-delta2,0,delta2],’Ycolor’,’r’);<br />

set(H1,’color’,’g’,’linewidth’,1); set(H2,’color’,’r’,’linewidth’,1);<br />

title(’Unweighted Ripples’,’fontsize’,TF,’vertical’,’baseline’);<br />

ylabel(’Amplitude’,’vertical’,’cap’)<br />

xlabel(’Frequency in \pi units’,’vertical’,’middle’);<br />

The responses of the designed FIR filter are given in Figure 9.25. This filter<br />

passes the signal spectrum over the passband [0,π/2] without any distortion.<br />

However, since the transition width is not very narrow, it is possible that some<br />

of the signal over the transition band may alias into the band of interest. Also<br />

the 30 db attenuation may allow a small fraction of the signal spectrum from the<br />

stopband into the passband after downsampling. Therefore, we need a better<br />

approach for filter specifications, as discussed further along in this section. □<br />

MATLAB Implementation As discussed, the upfirdn function can<br />

also be used for implementing the user-designed FIR filter in the decimation<br />

operation. When invoked as y = upfirdn(x,h,1,D), the function<br />

filters the signal data in the array x with the impulse response given in<br />

the array h and then downsamples the filtered data by the integer factor<br />

D to produce the output array y, thus implementing the system in<br />

Figure 9.24.<br />

□ EXAMPLE 9.12 Using the filter designed in Example 9.11 decimate sinusoidal signals x 1(n)=<br />

cos(πn/8) and x 2(n)= cos(πn/2) with frequencies within the passband of the<br />

filter. Verify the performance of the FIR filter and the results of the decimation.<br />

Solution<br />

The following MATLAB script provides the details.<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!