interp | R Documentation |
Upsample a signal by a constant factor by using an FIR filter to interpolate between points.
interp(x, q, n = 4, Wc = 0.5)
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. |
It uses an order 2*q*n+1
FIR filter to interpolate between samples.
The upsampled signal, an array of length q * length(x)
.
Original Octave version by Paul Kienzle pkienzle@user.sf.net. Conversion to R by Tom Short.
https://en.wikipedia.org/wiki/Upsampling
Octave Forge https://octave.sourceforge.io/
fir1
, resample
, interp1
, decimate
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.