interp {signal}R Documentation

Interpolate / Increase the sample rate

Description

Upsample a signal by a constant factor by using an FIR filter to interpolate between points.

Usage

interp(x, q, n = 4, Wc = 0.5)

Arguments

x

the signal to be upsampled.

q

the integer factor to increase the sampling rate by.

n

the FIR filter length.

Wc

the FIR filter cutoff frequency.

Details

It uses an order 2*q*n+1 FIR filter to interpolate between samples.

Value

The upsampled signal, an array of length q * length(x).

Author(s)

Original Octave version by Paul Kienzle pkienzle@user.sf.net. Conversion to R by Tom Short.

References

https://en.wikipedia.org/wiki/Upsampling

Octave Forge https://octave.sourceforge.io/

See Also

fir1, resample, interp1, decimate

Examples

# The graph shows interpolated signal following through the
# sample points of the original signal.
t <- seq(0, 2, by = 0.01)
x <- chirp(t, 2, 0.5, 10, 'quadratic') + sin(2*pi*t*0.4)
y <- interp(x[seq(1, length(x), by = 4)], 4, 4, 1) # interpolate a sub-sample
plot(t, x, type = "l")
idx <- seq(1,length(t),by = 4)
lines(t, y[1:length(t)], col = "blue")
points(t[idx], y[idx], col = "blue", pch = 19)

[Package signal version 1.8-1 Index]