ScaleTime

Versión 2.0.0.0 (18,3 KB) por Jan
Fast linear interpolation of equally spaced data (C-MEX and M)
2,8K descargas
Actualizado 20 oct 2020

Ver licencia

ScaleTime - fast linear matrix interpolation

Yi = ScaleTime(Y, T)
Where T is a vector with values between 1 and size(Y,1). This is equivalent to
Yi = interp1(1:size(Y, 1), Y, T, 'linear')
If T is defined by uniform steps: T = linspace(Ti, Tf, Tn) this is faster:
Yi = ScaleTime(Y, Ti, Tf, Tn)

For nun-uniform input use the 2nd function:
Yi = ScaleTimeNU(X, Y, Xi)

I have recorded timeseries of e.g. size [100'000 x 10] and cut out chunks of about 100 frames according to some events and normalize them to 101 frames.
The direct approach with Matlab's INTERP1 works, but it is slow:
interp1(1:size(Y, 1), Y, Ti, '*linear')

Therefore I've created the function ScaleTime for:
- linear interpolation
- equally spaced input data
- equally or non-equally spaced interpolation steps
- matrix input
- no handling of NaNs, no extrapolation.

To my surprise, ScaleTime is remarkably faster than INTERP1 and even the modern griddedInterpolant.
The functions lininterp1f and qinterp1 from the FEX do not accept matrices and they are significantly slower than the MEX ScaleTime:
http://www.mathworks.com/matlabcentral/fileexchange/8627
http://www.mathworks.com/matlabcentral/fileexchange/10286
If you have installed these tools, their speed is compared in uTest_ScaleTime.

Included: M-source, C-source.
Compilation: Automatically at running ScaleTime the first time, or:
mex -O ScaleTime.c
Pre-compiled mex function coming soon on: http://n-simon.de/mex

Citar como

Jan (2024). ScaleTime (https://www.mathworks.com/matlabcentral/fileexchange/25463-scaletime), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2018b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Categorías
Más información sobre Time Series Objects en Help Center y MATLAB Answers.
Agradecimientos

Inspirado por: Fast Linear Interpolation, Fast interpolation

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versión Publicado Notas de la versión
2.0.0.0

Bug fix in test function, double and single input. A 2nd function for treating non-uniform inputs is added.

1.0.0.0