1
$\begingroup$

Does anyone know what algorithm is implemented in the Matlab function resample for timeseries?

I had a look on the manual but it just gives the instruction to use it: http://it.mathworks.com/help/matlab/ref/resampletscollection.html

Since the syntax is different from the one used for the usual resample (http://it.mathworks.com/help/ident/ref/resample.html) I assumed is not the same algorithm. Am I right?

$\endgroup$
0
$\begingroup$

You can directly edit the code with open resample and browse the different options. INgredients are border (zero padding, border trimming) and delay management, filter design (uniform or firls with kaiser) before the use of upfirdn for antialiasing. A snippet of the function's help.

%   Y = RESAMPLE(X,P,Q,N) uses a weighted sum of 2*N*max(1,Q/P) samples of X 
%   to compute each sample of Y.  The length of the FIR filter RESAMPLE applies
%   is proportional to N; by increasing N you will get better accuracy at the 
%   expense of a longer computation time.  If you don't specify N, RESAMPLE uses
%   N = 10 by default.  If you let N = 0, RESAMPLE performs a nearest
%   neighbor interpolation; that is, the output Y(n) is X(round((n-1)*Q/P)+1)
%   ( Y(n) = 0 if round((n-1)*Q/P)+1 > length(X) ).
%
%   Y = RESAMPLE(X,P,Q,N,BTA) uses BTA as the BETA design parameter for the 
%   Kaiser window used to design the filter.  RESAMPLE uses BTA = 5 if
%   you don't specify a value.
%
%   Y = RESAMPLE(X,P,Q,B) uses B to filter X (after upsampling) if B is a 
%   vector of filter coefficients.  RESAMPLE assumes B has odd length and
%   linear phase when compensating for the filter's delay; for even length 
%   filters, the delay is overcompensated by 1/2 sample.  For non-linear 
%   phase filters consider using UPFIRDN.
$\endgroup$
0
$\begingroup$

See http://www.mathworks.com/help/matlab/ref/timeseries.setinterpmethod.html Seems to a choice between a few fairly simple interpolation schemes. The standard resample() uses a polyphase filter interpolation which is much better for most applications.

$\endgroup$
  • $\begingroup$ i know that resample() does a better job, but the setinterpmethod link seems to indicate that it's a choice between zoh and linear with linear as the default. i can't believe that resample() is that bad. $\endgroup$ – robert bristow-johnson Jan 19 '15 at 17:14
  • $\begingroup$ A timeseries isn't the same thing as a signal in Matlab. $\endgroup$ – John Aug 13 '16 at 3:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.