interp | R Documentation |
Increase sample rate by integer factor.
interp(x, q, n = 4, Wc = 0.5)
x |
input data, specified as a numeric vector. |
q |
interpolation factor, specified as a positive integer. |
n |
Half the number of input samples used for interpolation, specified
as a positive integer. For best results, use |
Wc |
Normalized cutoff frequency of the input signal, specified as a positive real scalar not greater than 1 that represents a fraction of the Nyquist frequency. A value of 1 means that the signal occupies the full Nyquist interval. Default: 0.5. |
interpolated signal, returned as a vector.
Paul Kienzle, pkienzle@users.sf.net.
Conversion to R by Geert van Boxtel G.J.M.vanBoxtel@gmail.com.
decimate
, resample
# Generate a signal
t <- seq(0, 2, 0.01)
x <- chirp(t, 2, .5, 10,'quadratic') + sin(2 * pi * t * 0.4)
w <- seq(1, 121, 4)
plot(t[w] * 1000, x[w], type = "h", xlab = "", ylab = "")
points(t[w] * 1000, x[w])
abline (h = 0)
y <- interp(x[seq(1, length(x), 4)], 4, 4, 1)
lines(t[1:121] * 1000, y[1:121], type = "l", col = "red")
points(t[1:121] * 1000, y[1:121], col = "red", pch = '+')
legend("topleft", legend = c("original", "interpolated"),
lty = 1, pch = c(1, 3), col = c(1, 2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.