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.

502 Chapter 9 SAMPLING RATE CONVERSION<br />

Hf1 = figure(’units’,’inches’,’position’,[1,1,6,4],...<br />

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

subplot(2,2,1); Hs1 = stem(n,h,’filled’); set(Hs1,’markersize’,2);<br />

axis([-1,length(n),-0.5,1.5]); ylabel(’Amplitude’); xlabel(’n’,’vertical’,’bottom’);<br />

Title(’Impulse Response’,’fontsize’,TF);<br />

subplot(2,2,3); plot(ww/pi,Hr,’m’,’linewidth’,1.0); axis([0,1,-1,6]);<br />

set(gca,’xtick’,[0,wp/pi,ws/pi,1],’ytick’,[0,I]); grid; ylabel(’Amplitude’);<br />

title(’Amplitude Response’,’fontsize’,TF); xlabel(’Frequency in \pi units’);<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’);<br />

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

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

lw = length(w)-1; PB = [0:floor(wp/pi*lw)]; HrPB = Hr(PB+1)-I;<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*I*100)/100; delta2 = round(delta2*I*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(’Scaled Ripples’,’fontsize’,TF); xlabel(’Frequency in \pi units’);<br />

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

though this filter passes the original signal, it is possible that some of the neighboring<br />

spectral energy may also leak through if the signal is of full bandwidth<br />

of π radians. Hence we need better design specifications, which are discussed<br />

further along in this section.<br />

□<br />

MATLAB Implementation To use the FIR filter for interpolation<br />

purposes (such as the one designed in Example 9.8), MATLAB has provided<br />

a general function, upfirdn, that can be used for interpolation<br />

and decimation as well as for resampling purposes. Unlike other functions<br />

discussed in this chapter, upfirdn incorporates the user-defined FIR filter<br />

(which need not be linear phase) in the operation. When invoked as<br />

y = upfirdn(x,h,I), the function upsamples the input data in the array<br />

x by a factor of the integer I and then filters the upsampled signal data<br />

with the impulse response sequence given in the array h to produce the<br />

output array y, thus implementing the system in Figure 9.18.<br />

□ EXAMPLE 9.9 Let x(n) =cos(0.5πn). Increase the input sampling rate by a factor of I =5,<br />

using the filter designed in Example 9.8.<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!