upfirdn
R2026bUpsample, apply FIR filter, and downsample
Description
Examples
Input Arguments
Output Arguments
Tips
The valid combinations of the sizes of
xandhare:xis a vector andhis a vector.The inputs are one filter and one signal, so the function convolves
xwithh. The output signalyis a row vector ifxis a row vector; otherwise,yis a column vector.xis a matrix andhis a vector.The inputs are one filter and many signals, so the function convolves
hwith each column ofx. The resultingyis a matrix with the same number of columns asx.xis a vector andhis a matrix.The inputs are multiple filters and one signal, so the function convolves each column of
hwithx. The resultingyis a matrix with the same number of columns ash.xis a matrix andhis a matrix, both with the same number of columns.The inputs are multiple filters and multiple signals, so the function convolves corresponding columns of
xandh. The resultingyis a matrix with the same number of columns asxandh.
Assume you have an input signal with sample rate
Finand your task is to resample the signal toFoutYou can obtainpandqby using theratfunction, which finds the smallest integer conversion ratiop/q. This code show how to obtainpandqfromFinandFout.[P,Q] = rat(Fout/Fin)
Algorithms
The upfirdn function modifies the sample rate of a signal by an
integer ratio P/Q. The function performs a cascade of three operations:
The upfirdn function uses a polyphase interpolation structure.
The number of multiply-add operations in the polyphase structure is approximately (LhLx
– pLx)/q where Lh and
Lx are the lengths of
h(n) and x(n),
respectively. For long signals, this formula is often exact.
The FIR filter is usually a lowpass filter, which you must design using another function
such as firpm or fir1. The quality of the output signal relies on the quality of the FIR filter
h.
References
[1] Crochiere, R. E. "A General Program to Perform Sampling Rate Conversion of Data by Rational Ratios." Programs for Digital Signal Processing (Digital Signal Processing Committee of the IEEE Acoustics, Speech, and Signal Processing Society, eds.). New York: IEEE Press, 1979, Programs 8.2-1–8.2-7.
[2] Crochiere, R. E., and Lawrence R. Rabiner. Multirate Digital Signal Processing. Englewood Cliffs, NJ: Prentice-Hall, 1983.



