Resampling at a different frequency

Calling sequence

y = resample(x,R);
y = resample(x,R,itrp);



Input signal (1d vector)


Decimation (R < 1) / upsampling (R > 1) factor, e.g. ratio between the output and input sample frequency.


Interpolator object (default is cardinal spline)


Output signal, resampled at input frequency * R


Time-domain based alternative to native Scilab intdec function (which is DFT based). The advantages compared to the intdec function are:

  • No spectral leakages effects due to different values at the beginning and end of the signal,

  • Better mastering of the frequency response (aliasing rejection), contrary to DFT method.

  • The possibility to choose the interpolation algorithm to use (currently supported: cardinal cubic splines, linear and lagrange).

The default implementation is based on the cardinal cubic spline interpolator.


fs1 = 10; fs2 = 100; // Input and output sample rates
t1 = (0:1/fs1:1)';
t2 = (0:1/fs2:1)';
x = t1; // Signal to interpolate
// Interpolation (intdec VS resample)
yi = intdec(x, fs2/fs1);
yr = resample(x, fs2/fs1);
// Trunk the end of interpolated signals
yi = yi(1:length(t2)); yr = yr(1:length(t2));
// Plotting
clf(); plot(t1,x,'sb'); plot(t2,yi,'r'); plot(t2,yr,'g');

Comparison between intdec (DFT based) aand resample (interpolator based)

Note the importance of the leakage effects in intdec function, due to the hypothesis of periodicity (introducing a big discontinuity between the end and the begin of the signal).

See also