Engee documentation

interp

Interpolation is an increase in the sampling rate by an integer number of times.

Library

EngeeDSP

Syntax

Function call

  • y = interp(x,r) — increases the sampling rate of the input signal x in r once.

  • y = interp(x,r,n,cutoff) — defines two additional values:

    • n — half of the number of initial sample values used for interpolation of the extended signal.

    • cutoff — the normalized cutoff frequency of the input signal, set as a fraction of the Nyquist frequency.

  • y,b = interp(x,r,n,cutoff) — also returns the filter coefficients used for interpolation.

Arguments

Input arguments

# x — input signal

+ vector

Details

The input signal is set as a vector.

Типы данных

Float64, Float32

# r is the interpolation coefficient

+ a positive integer

Details

The interpolation coefficient, set as a positive integer.

Типы данных

Float64, Float32

# n is half the number of input sample values used for interpolation

+ 4 (by default) | a positive integer

Details

Half of the number of input sample values used for interpolation, set as a positive integer. For best results, use n no more than 10. The length of the low-pass interpolation filter is 2 × n × r + 1.

Типы данных

Float64, Float32

# cutoff — normalized cutoff frequency

+ 0.5 (by default) | positive scalar

Details

The normalized cutoff frequency of the input signal, set as a positive real number of no more than 1, which is a part of the Nyquist frequency. Meaning 1 This means that the signal occupies the entire Nyquist interval.

Типы данных

Float64, Float32

Output arguments

# y — interpolated signal

+ vector

Details

The interpolated signal returned as a vector. Argument y in r times longer than the original input vector x.

Типы данных

Float64, Float32

# b — coefficients of the low-pass interpolation filter

+ column vector

Details

The coefficients of the low-pass interpolation filter returned as a column vector.

Типы данных

Float64, Float32

Examples

Signal interpolation

Details

Let’s create a sinusoidal signal with a sampling frequency 1 kHz. We interpolate it with the coefficient 4.

import EngeeDSP.Functions: interp

t = 0:1/1e3:1
x = sin.(2π*30*t) .+ sin.(2π*60*t)
y = interp(x, 4).y

Let’s plot the original and interpolated signals.

plot(
    plot(0:30, x[1:31], seriestype = :stem, markershape = :circle, markerstrokewidth = 0, markersize = 3,
         xlabel = "Sample Number", ylabel = "Original", grid = true),
    plot(0:120, y[1:121], seriestype = :stem, markershape = :circle, markerstrokewidth = 0, markersize = 3,
         xlabel = "Sample Number", ylabel = "Interpolated", grid = true),
    layout = (2, 1)
)

interp

Algorithms

Interpolation increases the initial sampling rate of the sequence. This is the opposite of thinning. Function interp inserts zeros into the original signal, and then applies a low-pass interpolation filter to the extended sequence. The function uses the low-pass interpolation algorithm 8.1 described in [1]:

  1. Expand the input vector to the desired length by inserting zeros between the original data values.

  2. To design a special symmetric FIR filter that passes the original data unchanged and interpolates them to minimize the RMS error between the interpolated points and their ideal values. The filter used by the function interp, matches the filter returned by intfilt.

  3. Apply a filter to the expanded input vector to get the output value.

Literature

  1. Digital Signal Processing Committee of the IEEE Acoustics, Speech, and Signal Processing Society, eds. Programs for Digital Signal Processing. New York: IEEE Press, 1979.

  2. Oetken, G., Thomas W. Parks, and H. W. Schüssler. «New results in the design of digital interpolators.» IEEE® Transactions on Acoustics, Speech, and Signal Processing. Vol. ASSP-23, No. 3, June 1975, pp. 301–309.