Learn R Programming

signal (version 0.5)

interp: 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.

Value

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

Details

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

References

http://en.wikipedia.org/wiki/Upsampling Octave Forge http://octave.sf.net

See Also

fir1, resample, interp1, decimate

Examples

Run this code
# 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,.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)

Run the code above in your browser using DataLab