File Exchange

image thumbnail

resampleX

version 1.0 (2.83 KB) by

Resample time series

3 Downloads

Updated

View License

Resamples X(n). Y(n) = X(alpha*n), where alpha is a resample interval. For example, if X is data sampled at 1000 samples per second and you would like to transform it to the equivalent of 1100 samples per second use alpha= 1000/1100 (.9091); for 800 sample per second use alpha = 1000/800 (1.25).

ResampleX is similar to the MATLAB "resample" function (in the SignalProcesscing Toolbox). For most applications resampleX is much faster.

Comments and Ratings (4)

mahmoud

D M

When I run resampleX(x,1) I don't get x back. Something seems wrong here ...

Bill Winter

Line 94: m = round((0:(N2-1))/alpha) - (0:(N2-1));

You're essentially doing a nearest neighbor interpolation. You've upsampled the data by your factor of 'r,' but I believe that it's perfectly equivalent to running the command resample(X,r,r/alpha,0). Taking this into account, resampleX loses its speed advantage.

I do appreciate the fact that to run resample, r must be chosen to make r/alpha an integer. An exotic alpha could necessitate an enormous r to work in resample.

Updates

User commented that resampleX(x,1) did not return exatly x. The problem was tracked down and fixed. See comments in m file.

A user found a minor bug. The update has a fix, which improves the accuracy slightly.
Also, please note that there is a new screenshot, consistent with this new version.

Changes incorporate comments and sugestions made two users. Changes are summarized in the comments included in the new m file.

MATLAB Release
MATLAB 7.0.4 (R14SP2)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today