ZINTERP

Purpose:

Interpolates a series to a new sample rate by FFT zero insertion.

Syntax:

ZINTERP(series, r)

series

-

An input series or array.

r

-

A real. The new sample rate of the interpolated series, r > rate(series). Defaults to 2*rate(series).

Returns:

A series or array.

Example:

W1: gsin(64, 1/64, 10)

W2: zinterp(W1, 16*rate(W1));overp(w1);setplotstyle(1, 2);setsym(circle, 2)

 

image\zinterp1.png

 

W1 contains 64 samples of a 10 Hz sine wave sampled at 64 Hz.

 

W2 produces a 3 Hz sine wave with an interpolated sample rate of 64 * 16 = 1024 Hz. The length is 1009 samples. The original sine wave in W1 is overplotted as red circles. The interpolation result accurately constructs the underlying 10 Hz sine wave.

Example:

W3: zinterp(W1, 100)

 

produces a 99 point interpolated 3 Hz sine wave with a sample rate of 100 Hz.

Remarks:

ZINTERP effectively resamples the input series to the higher rate R using ideal sin(Nx)/sin(x) periodic interpolation. The interpolation is calculated by the following remarkably simple and efficient method:

 

1.

For series s, the FFT is calculated.

2.

N zeros are inserted into the FFT starting at the Nyquist frequency,

Fn = 0.5 * rate(s).

 

N is determined such that: 

 

 L / R = length(s) / rate(s)

 

where L is the length of the output series. Since: 

 

 L = length(s) + N

 

we have:  

 

 N = ((R * length(s)) / rate(s)) - length(s)

3.

The IFFT of the inserted series is computed to produce the interpolated time domain series.

 

The zero insertion step is equivalent to convolving the input series with a symmetric "continuous" periodic sin(Nx)/sin(x) window of the same length as the output series and then sampling this "continuous" waveform at the new rate. This is the precise definition of ideal sin(Nx)/sin(x) interpolation for a periodic time series. If the input series is band limited, that is, if the series can be thought of as having been obtained by sampling a continuous time signal at rate Fs and

 

 X(f) = 0 for f > 0.5 * Fs

 

where X(f) is the Fourier Transform of the continuous time signal, then the interpolation will be exact (within numerical roundoff errors).

 

Although the output rate R is NOT required to be an integer multiple of the input sample rate, the relation:

 

 R / rate(s) = L / length(s)

 

must hold, so the actual output rate might differ from R.

 

sin(Nx)/sin(x) interpolation can be thought of as periodic sin(x)/x (i.e. sinc) interpolation, i.e. for periodic waveforms, standard sin(x)/x interpolation is identical to periodic sin(Nx)/sin(x) interpolation. The sin(Nx)/sin(x) function acts as a periodic version of the sin(x)/x function.

 

For non-periodic waveforms, sin(Nx)/sin(x) interpolation produces the same result as sin(x)/x interpolation to within a few percent.

 

See RESAMPLE to resample a series to a specific sample rate using a variety of interpolation methods.

See Also:

FFT

FZINTERP

INTERPOLATE

POLYFIT

RESAMPLE

SPLINE