Note: This page has been translated by MathWorks. Please click here

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

Upsample, apply FIR filter, and downsample

* yout* = upfirdn(

`xin`

`h`

`yout`

`xin`

`h`

`p`

`yout`

`xin`

`h`

`p`

`q`

`upfirdn`

performs a cascade of three operations:

Upsampling the input data in the matrix

`xin`

by a factor of the integer`p`

(inserting zeros)FIR filtering the upsampled signal data with the impulse response sequence given in the vector or matrix

`h`

Downsampling the result by a factor of the integer

`q`

(throwing away samples)

`upfirdn`

has been implemented as a MEX-file
for maximum speed, so only the outputs actually needed are computed.
The FIR filter is usually a lowpass filter, which you must design
using another function such as `firpm`

or `fir1`

.

The function `resample`

performs
an FIR design using `firls`

,
followed by rate changing implemented with `upfirdn`

.

filters
the input signal * yout* = upfirdn(

`xin`

`h`

`xin`

with the FIR filter having
impulse response `h`

. If `xin`

is
a row or column vector, then it represents a single signal. If `xin`

is
a matrix, then each column is filtered independently. If `h`

is
a row or column vector, then it represents one FIR filter. If `h`

is
a matrix, then each column is a separate FIR impulse response sequence.
If `yout`

is a row or column vector, then it represents
one signal. If `yout`

is a matrix, then each column
is a separate output. No upsampling or downsampling is implemented
with this syntax.

specifies
the integer upsampling factor * yout* = upfirdn(

`xin`

`h`

`p`

`p`

,
where `p`

has a default value of 1.

specifies
the integer downsampling factor * yout* = upfirdn(

`xin`

`h`

`p`

`q`

`q`

,
where `q`

has a default value of 1.
The length of the output, `yout`

`ceil(((length(xin)-1)*p+length(h))/q)`

Since `upfirdn`

performs convolution and rate
changing, the `yout`

signals have a different length
than `xin`

. The number of rows of `yout`

is
approximately `p/q`

times the number of rows of `xin`

.

Usually the inputs `xin`

and the filter `h`

are
vectors, in which case only one output signal is produced. However,
when these arguments are arrays, each column is treated as a separate
signal or filter. Valid combinations are:

`xin`

is a vector and`h`

is a vector.There is one filter and one signal, so the function convolves

`xin`

with`h`

. The output signal`yout`

is a row vector if`xin`

is a row; otherwise,`yout`

is a column vector.`xin`

is a matrix and`h`

is a vector.There is one filter and many signals, so the function convolves

`h`

with each column of`xin`

. The resulting`yout`

will be an matrix with the same number of columns as`xin`

.`xin`

is a vector and`h`

is a matrix.There are many filters and one signal, so the function convolves each column of

`h`

with`xin`

. The resulting`yout`

will be an matrix with the same number of columns as`h`

.`xin`

is a matrix and`h`

is a matrix, both with the same number of columns.There are many filters and many signals, so the function convolves corresponding columns of

`xin`

and`h`

. The resulting`yout`

is an matrix with the same number of columns as`xin`

and`h`

.

`upfirdn`

uses a polyphase interpolation structure.
The number of multiply-add operations in the polyphase structure is
approximately (*L _{h}*

A more accurate flops count is computed in the program, but
the actual count is still approximate. For long signals *x*(*n*),
the formula is often exact.

[1] Crochiere, R. E., and Lawrence R. Rabiner. *Multirate
Digital Signal Processing*. Englewood Cliffs, NJ: Prentice-Hall,
1983, pp. 88–91.

[2] 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.

Was this topic helpful?