(5 votes, average: 5.00 out of 5)

# Zero-order hold and first-order hold based interpolation

by on March 25, 2007

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 $x(n) = \cos(\frac{2\pi n}{N})\ \ \ 0 \le n \le N-1$

while keeping the sampling frequency $F_s = 1/T$ unchanged.

My take:

The first part of the problem (a) is to generate the sequence $y(n)$ having half the frequency of $x(n)$. 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 $h_{ZOH}$ is a rectangular function i.e. $h_{ZOH} = [1 \ 1]$.

For the delayed first-order interpolation, the filter function $h_{FOH}$ is a triangular function i.e. $h_{FOH} = [1\ 2\ 1]/2$. 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 $H_{ZOH}$ is a $sinc()$ shaped function whereas for the first order hold, $H_{FOH}$, the transfer function is a $sinc^2()$ shaped function.

As $sinc^2(x) \le sinc(x)$ for all $x$, 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 $x(n)$ having a triangular spectrum is to be passed first through the zero insertion block to generate $x_i(n)$ followed by the filtering operation to generate $y(n)$.

With the sampling frequency $F_s$ kept unchanged, insertion of zeros causes the signal bandwidth to be half the original spectrum, additionally the spectrum gets aliased to be around $\frac{F_s}{2}$.

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 $F_s$. The high frequency components present around $F_s$ 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, John G. Proakis, Dimitris G. Manolakis

D id you like this article? Make sure that you do not miss a new article by subscribing to RSS feed OR subscribing to e-mail newsletter. Note: Subscribing via e-mail entitles you to download the free e-Book on BER of BPSK/QPSK/16QAM/16PSK in AWGN.

{ 0 comments… add one now }

Previous post:

Next post: