Digital Signal Processing Reference
In-Depth Information
xb2=[xn(4) xn(5) xn(6)]
xb3=[xn(7) xn(8) xn(9)]
% zero pad the blocks to 4 elements
xb1p=[xb1 0]
xb2p=[xb2 0]
xb3p=[xb3 0]
% zero pad hn to 4 elements
hp=[hn 0 0]
% Compute the DFT of each zero-padded block of input data.
X1=fft(xb1p);
X2=fft(xb2p);
X3=fft(xb3p);
% Compute the DFT of the zero-padded impulse response.
Hp=fft(hp)
% Multiply the H[k] and X[k]to calculate Y[k] for each block.
Y1=Hp.*X1;
Y2=Hp.*X2;
Y3=Hp.*X3;
% Compute IDFT[Y[k]] = y[n], for each block of output data.
y1=ifft(Y1);
y2=ifft(Y2);
y3=ifft(Y3);
% Shift each block of output into the proper time slot.
y1s=[y1 0 0 0 0 0 0];
y2s=[0 0 0 y2 0 0 0];
y3s=[0 0 0 0 0 0 y3];
% Add the shifted, zero-padded output blocks to form the output signal.
y=y1s+y2s+y3s;
% Display the first 9 elements of the output signal.
yp=y(1,1:9)
% Calculate the output signal using convolution to compare results.
yn=conv(hn,xn)
% Prepare data for plotting.
y1sp=y1s(1,1:9);
y2sp=y2s(1,1:9);
n=0:8;
stem(n,y1sp,'filled')
figure(2)
stem(n,y2sp, 'filled')
figure(3)
stem(n,yp,'filled')
We see that the DFT is useful for filtering discrete-time sequences. For cases
where the input sequence is too long to allow the convolution operation to be com-
puted directly, we have discussed the overlap-add method of block filtering. Block
filtering allows us to break the input sequence into manageable-length sequences
for convolution with the filter's unit impulse response.
 
Search WWH ::




Custom Search