x: input data, specified as a numeric vector or matrix. In case of a vector it represents a single signal; in case of a matrix each column is a signal.
p, q: resampling factors, specified as positive integers. p / q
is the resampling factor.
h: Impulse response of the FIR filter specified as a numeric vector or matrix. If it is a vector, then it represents one FIR filter to may be applied to multiple signals in x; if it is a matrix, then each column is a separate FIR impulse response. If not specified, a FIR filter based on a Kaiser window is designed.
Returns
output signal, returned as a vector or matrix. Each column has length ceiling(((length(x) - 1) * p + length(h)) / q)..
Details
If h is not specified, this function will design an optimal FIR filter using a Kaiser-Bessel window. The filter length and the parameter β
are computed based on ref [2], Chapter 7, Eq. 7.63 (p. 476), and Eq. 7.62 (p. 474), respectively.
Examples
lx <-60tx <- seq(0,360, length.out = lx)x <- sin(2* pi * tx /120)# upsamplep <-3; q <-2ty <- seq(0,360, length.out = lx * p / q)y <- resample(x, p, q)# downsamplep <-2; q <-3tz <- seq(0,360, length.out = lx * p / q)z <- resample(x, p, q)# plotplot(tx, x, type ="b", col =1, pch =1, xlab ="", ylab ="")points(ty, y, col =2, pch =2)points(tz, z, col =3, pch =3)legend("bottomleft", legend = c("original","upsampled","downsampled"), lty =1, pch =1:3, col =1:3)
References
[1] Proakis, J.G., and Manolakis, D.G. (2007). Digital Signal Processing: Principles, Algorithms, and Applications, 4th ed., Prentice Hall, Chap. 6.
[2] Oppenheim, A.V., Schafer, R.W., and Buck, J.R. (1999). Discrete-time signal processing, Signal processing series, Prentice-Hall.