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


ZINTERP(series, r)



An input series or array.



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


A series or array.


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

W2: zinterp(W1, 4*rate(W1))


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


W2 produces a 3 Hz sine wave with an interpolated sample rate of 64 * 4 = 256 Hz. The length is 253 samples.


W3: zinterp(W1, 100)


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


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



For series s, the FFT is calculated.


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)


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 sinx/sin 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 sinx/sin 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.


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


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


ZINTERP also works on arrays.


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

See Also: