Signal Processing Toolbox
  Go to function:
    Search    Help Desk 
resample    Examples   See Also

Change sampling rate by any factor.



y = resample(x,p,q) resamples the sequence in vector x at p/q times the original sampling rate, using a polyphase filter implementation. The length of y is equal to ceil(length(x)*p/q). p and q must be positive integers. If x is a matrix, resample works down the columns of x.

resample applies an anti-aliasing (lowpass) FIR filter to x during the resampling process. It designs the filter using fir1 with a Kaiser window.

y = resample(x,p,q,n) uses n terms on either side of the current sample, x(k), to perform the resampling. The length of the FIR filter resample uses is proportional to n; larger values of n provide better accuracy at the expense of more computation time. The default for n is 10. If you let n = 0, resample performs a nearest-neighbor interpolation:

where y(k) = 0 if the index to x is greater than length(x).

y = resample(x,p,q,n,beta) uses beta as the design parameter for the Kaiser window that resample employs in designing the lowpass filter. The default for beta is 5.

y = resample(x,p,q,b) filters x with b, a vector of filter coefficients.

[y,b] = resample(x,p,q) returns the vector b, which contains the coefficients of the filter applied to x during the resampling process.


Resample a simple linear sequence at 3/2 the original rate:

Notice that the last few points of the output y are inaccurate. In its filtering process, resample assumes the samples at times before and after the given samples in x are equal to zero. Thus large deviations from zero at the end points of the sequence x can cause inaccuracies in y at its end points. The following two plots illustrate this side effect of resample:


If p or q are not positive integers, resample gives the appropriate error message:

If x is not a vector, resample gives the following error message:

See Also

Decrease the sampling rate for a sequence (decimation).
Window-based finite impulse response filter design--standard response.
Increase sampling rate by an integer factor (interpolation).
One-dimensional data interpolation (table lookup) (see the online MATLAB Function Reference).
Interpolation FIR filter design.
Kaiser window.
Cubic spline interpolation (see the online MATLAB Function Reference).
Upsample, apply an FIR filter, and downsample.

[ Previous | Help Desk | Next ]