Signal Processing Toolbox |
Resampling
The toolbox provides a number of functions that resample a signal at a higher or lower rate.
Operation |
Function |
Apply FIR filter with resampling |
|
Cubic spline interpolation |
|
Decimation |
|
Interpolation |
|
Other 1-D interpolation |
|
Resample at new rate |
|
The resample
function changes the sampling rate for a sequence to any rate that is a ratio of two integers. The basic syntax for resample
is
where the function resamples the sequence x
at p/q
times the original sampling rate. The length of the result y
is p/q
times the length of x
.
One resampling application is the conversion of digitized audio signals from one sampling rate to another, such as from 48 kHz (the digital audio tape standard) to 44.1 kHz (the compact disc standard).
The example file contains a length 4001 vector of speech sampled at 7418 Hz:
clear load mtlb whos Name Size Bytes Class Fs 1x1 8 double array mtlb 4001x1 32008 double array Grand total is 4002 elements using 32016 bytes Fs Fs = 7418
To play this speech signal on a workstation that can only play sound at 8192 Hz, use the rat
function to find integers p
and q
that yield the correct resampling factor:
Since p/q*Fs = 8192.05
Hz, the tolerance of 0.0001 is acceptable; to resample the signal at very close to 8192 Hz:
resample
applies a lowpass filter to the input sequence to prevent aliasing during resampling. It designs this filter using the firls
function with a Kaiser window. The syntax
controls the filter's length and the beta parameter of the Kaiser window. Alternatively, use the function intfilt
to design an interpolation filter b
and use it with
The decimate
and interp
functions do the same thing as resample
with p
= 1
and q
= 1
, respectively. These functions provide different anti-alias filtering options, and they incur a slight signal delay due to filtering. The interp
function is significantly less efficient than the resample
function with q
= 1
.
The toolbox also contains a function, upfirdn
, that applies an FIR filter to an input sequence and outputs the filtered sequence at a sample rate different than its original. See Multirate Filter Bank Implementation.
The standard MATLAB environment contains a function, spline
, that works with irregularly spaced data. The MATLAB function interp1
performs interpolation, or table lookup, using various methods including linear and cubic interpolation.
Frequency-Domain Based Modeling | Cepstrum Analysis |
© 1994-2005 The MathWorks, Inc.