Resampling

Resampling operations

Noninteger Delay

Non-integer delay, interpolation between samples, but the sample rate stays the same.

Down Sampling

sampling rate compressor
x_d[n] = x[nM] = x_c(nMT)

Up Sampling

sampling rate extender

x_u[n] = x[n/L], n = 0, +-L
          0 otherwise

General Resampling

Up sample (interpolate) from T to T/L then down sample (decimate) to T M/L. Changes sample rate by a rational factor.

Resampling functions in Matlab

OperationFunction
Resample at a new rate resample
Decimation decimate
Interpolation interp
Apply FIR filter with resampling upfirdn
Cubic spline interpolation spline
Other 1-D interpolation interp1

The resample function changes the sample rate for a sequence to any rate that is a ratio of two integers. The basic syntax is

   y = resample(x,p,q)

where the function resamples the sequence x at p/q times the original sampling rate.

The decimate and interp functions do the same thing as resample with p=1 and q=1 respectively. These functions provide different anti-aliasing filtering options, and they incur a slight delay due to filtering. The interp function is significantly less efficient than the resample function with q=1.

Example

One resampling operation 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). In this example, the sampling rates are different but the idea is the same.

>> clear
>> load mtlb
>> whos
  Name       Size         Bytes  Class
  Fs         1x1              8  double array
  mtlb    4001x1          32008  double array

>> Fs

Fs = 7418

To play this speech signal on a workstation htat can only play sound at 8192 Hz, use the rat function to find integers p and q that yield the correct resampling factor:

>> [p,q] = rat(8192/Fs,0.0001)

p = 127
q = 115

To resample the signal:

>> y = resample(mtlb,p,q);
>> whos
  Name       Size         Bytes  Class
  mtlb    4001x1          32008  double array
  y       4419x1          35352  double array

The actual resampled rate is Fs*p/q = 8192.05 Hz, which is sufficiently close to 8192 Hz.


Maintained by John Loomis, last updated 30 Sept 1997