**- DSP log - http://www.dsplog.com -**

Zero-order hold and first-order hold based interpolation

Posted By __Krishna Sankar__ On March 25, 2007 @ 10:55 am In __Filter__ | __15 Comments__

In problem 9.14 of DSP-Proakis, the objective is to analyze the effect of zero-order interpolation and first-order interpolation to double the number of samples in the sinusoidal

while keeping the sampling frequency unchanged.

My take:

The first part of the problem (a) is to generate the sequence having half the frequency of . For zero-order interpolation, the interpolated samples can be generated by holding the current sample till the new sampling instant (Ref: Section 9.3.1 -Sample and Hold [1]). The impulse response of such a system is a rectangular function.

For first-order interpolation with delay, the interpolated samples are generated by piece wise linear interpolation between the current sample and the previous sample. As the prediction based on current sample and previous sample can have ‘jumps’ at the next sampling instant, delay of one sample is provided (Ref: Section 9.3.3 – Linear interpolation with delay [1]). The impulse response of such a system is a triangular function.

For constructing these sample from MATLAB, let us use the technique provided in part (c) of the problem i.e. add zeros and pass it through a filter for obtaining the interpolated samples.

For zero-order interpolation, the filter function is a rectangular function i.e. .

For the delayed first-order interpolation, the filter function is a triangular function i.e. . The factor of 1/2 is for normalization.

% interpolation N = 32; x = cos(2*pi*(1/N)*[0:2*N-1]); xu = [ x ; zeros(size(x))]; xu = xu(:).'; % upsampled version of x h_zoh = [1 1]; h_foh = [1 2 1]/2; y_zoh = conv(xu, h_zoh); % zero-order hold y_foh = conv(xu, h_foh); % delayed first order hold y_pfct = cos(2*pi*(1/(2*N))*[0:2*N-1]); % perfect sine y_zoh = y_zoh(1:64); % taking one period of the cosine y_foh = y_foh(2:65); % % one period of cosine with delay removed plot(y_pfct,'r'); hold on; grid on plot(y_zoh,'b'); plot(y_foh,'m'); legend('pfct', 'zoh', 'foh') xlabel('sample index, n') ylabel('y(n)') title('one period of the sinusoidal')

For the first-order interpolation case, note that the effect of delay is removed and plotted.

Let us further analyze the harmonic distortion from the generated sinusoidal’s.

% compute the fourier series coefficients k = [0:N-2]'; refF = exp(-j*2*pi*k*[0:2*N-1]*(1/(2*N))); hd_y_pfct = mean((ones(N -1,1)*y_pfct).*refF,2); hd_y_zoh = mean((ones(N-1,1)*y_zoh(1:64)).*refF,2); hd_y_foh = mean((ones(N -1,1)*y_foh(1:64)).*refF,2); % THD from perfect cosine function THD_y_pfct = 1 - 2*abs(hd_y_pfct(2)).^2/sum(y_pfct.^2/length(y_pfct)) % THD from zero-order hold based cosine function THD_y_zh = 1 - 2*abs(hd_y_zoh(2)).^2/sum(y_zh.^2/length(y_zoh)) % THD from first-order holds based cosine function THD_y_fh = 1 - 2*abs(hd_y_foh(2)).^2/sum(y_fh.^2/length(y_foh))

As can be seen from the simulations, the harmonic distortion from zero-order hold is higher than the distortion observed from the first-order hold. The probable explanation can be as follows:

% analyzing the transfer functions h_zoh = [1 1 ]; h_foh = [1 2 1]/2; H_zoh = fft(h_zoh, 1024); % 1024 pt fft of zero order hold filter H_foh = fft(h_foh, 1024); % 1024 pt fft of first order hold filter figure plot([-512:511]/1024,fftshift(abs(H_zoh))); hold on plot([-512:511]/1024,fftshift(abs(H_foh)),'r'); grid on xlabel('normalized frequency'); ylabel('amplitude'); title('freuqency response') legend('zoh', 'foh')

From the frequency domain transfer functions, it can be seen that zero-order interpolation has a slightly relaxed transfer function for high frequency components when compared to the transfer function of first-order interpolation.

Analytically, for the zero-order interpolation, the transfer function is a shaped function whereas for the first order hold, , the transfer function is a shaped function.

As for all , it can be argued that thought the desired frequency in first-order hold is slightly more attenuated when compared to the zero-order hold, the higher frequency components are more significantly attenuated first-order interpolation. Hence the better performance.

From a time domain perspective, it can be seen that the waveform obtained from first-order interpolation has a closer match with the ‘perfect wave’ when compared with the waveform obtained from zero-order interpolation.

For part (e) of the problem, when the input samples having a triangular spectrum is to be passed first through the zero insertion block to generate followed by the filtering operation to generate .

With the sampling frequency kept unchanged, insertion of zeros causes the signal bandwidth to be half the original spectrum, additionally the spectrum gets aliased to be around .

Note that, typically no one would want to distort the original spectrum and hence sampling frequency typically gets doubled when zeros are inserted (over-sampled). In that scenario, shape of the original spectrum centered around-dc remained unchanged, however with the spectrum gets aliased to around . The high frequency components present around need to be removed by a digital filter. Sauch a circuit having “*over sampling followed by digital filtering”* is used in typical transmitter implementation.

References:

[1] Digital Signal Processing – Principles, Algorithms and Applications ^{[1]}, John G. Proakis, Dimitris G. Manolakis

Article printed from DSP log: **http://www.dsplog.com**

URL to article: **http://www.dsplog.com/2007/03/25/zero-order-hold-and-first-order-hold-based-interpolation/**

URLs in this post:

[1] Digital Signal Processing – Principles, Algorithms and Applications: **http://www.amazon.com/Digital-Signal-Processing-Principles-Applications/dp/8120311299**

[2] zero order: **http://technorati.com/tags/zero%20order**

[3] first order: **http://technorati.com/tags/first%20order**

[4] interpolation: **http://technorati.com/tags/interpolation**

[5] click here to SUBSCRIBE : **http://www.feedburner.com/fb/a/emailverifySubmit?feedId=1348583&loc=en_US**

Click here to print.

Copyright © 2007-2012 dspLog.com. All rights reserved. This article may not be reused in any fashion without written permission from http://www.dspLog.com.