02.10.2019 Views

UploadFile_6417

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

186 Chapter 5 THE DISCRETE FOURIER TRANSFORM<br />

%%\leftskip12pt<br />

function [y] = ovrlpsav(x,h,N)<br />

% Overlap-Save method of block convolution<br />

% ----------------------------------------<br />

% [y] = ovrlpsav(x,h,N)<br />

% y = output sequence<br />

% x = input sequence<br />

% h = impulse response<br />

% N = block length<br />

%<br />

Lenx = length(x); M = length(h); M1 = M-1; L = N-M1;<br />

h = [h zeros(1,N-M)];<br />

%<br />

x = [zeros(1,M1), x, zeros(1,N-1)]; % preappend (M-1) zeros<br />

K = floor((Lenx+M1-1)/(L)); % # of blocks<br />

Y = zeros(K+1,N);<br />

% convolution with succesive blocks<br />

for k=0:K<br />

xk = x(k*L+1:k*L+N);<br />

Y(k+1,:) = circonvt(xk,h,N);<br />

end<br />

Y = Y(:,M:N)’;<br />

% discard the first (M-1) samples<br />

y = (Y(:))’;<br />

% assemble output<br />

Note: The ovrlpsav function as developed here is not the most efficient<br />

approach. We will come back to this issue when we discuss the fast Fourier<br />

transform.<br />

□ EXAMPLE 5.19 To verify the operation of the ovrlpsav function, let us consider the sequences<br />

given in Example 5.18.<br />

Solution<br />

MATLAB script:<br />

>> n = 0:9; x = n+1; h = [1,0,-1]; N = 6; y = ovrlpsav(x,h,N)<br />

y =<br />

1 2 2 2 2 2 2 2 2 2 -9 -10<br />

This is the correct linear convolution as expected.<br />

□<br />

There is an alternate method called an overlap-add method of block<br />

convolutions. In this method the input sequence x(n) ispartitioned into<br />

nonoverlapping blocks and convolved with the impulse response. The resulting<br />

output blocks are overlapped with the subsequent sections and<br />

added to form the overall output. This is explored in Problem P5.32.<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!