View Full Version : Re: Summary of time normalization in matlab

05-23-2002, 08:21 PM
Here's a sample of some of the issues raised in the replies
to my original query on interpolation methods in matlab.
Thanks to all the people who replied. You've all been a
great help.

I'm still thinking what procedure is most appropriate for
my data set and i will be getting in touch with a few
people to discuss some of the points raised.



FROM: Reed Ferber Ph.D. CAT(C) ATC


Use the function interpft

INTERPFT 1-D interpolation using FFT method.
Y = INTERPFT(X,N) returns a vector Y of length N obtained by interpolation
in the Fourier transform of X.

Thus, Y is your interpolated data, X is your matrix of whatever length you
wish to change and N is the length you want it to be interpolated to. In
other words:


will return data normalized to 100 points. However, be very careful about
"end-effects". You can find a very thorough discussion on this in the
Biomech-L archives. In brief, if you interpolate a matrix of less than 100
points, you will have irregular data at either end of your data set due to
the mathematics behind the fast fourier transformation. It is ideal to
have greater than 100 points in the original data set and then interpolate
DOWN to 100 points (or whatever length you choose).

I hope this is helpful



FROM: Peter Mills

Hi Mark,

I have used the built-in function "interp1.m" for temporal
normalisation of multiple cycles. In the following example, cycrows
is the number of rows in the time series for a single cycle, rfc(i) is
the time index of initial right foot contact and rfc(i+1) is the time
index of the subsequent right foot contact, coord is the [x, y]
coordinate matrix for consecutive cycles and coord101 is the
temporally normalised coordinate matrix for a single cycle.

This is a simplified version of my code that will work for a single
cycle but feel free to modify it for batch processing.


FROM: Robin Roithner

Dear Chen,

MATLAB offers the possibility of time normalization using spline interpolation. Look at help spline in MATLAB:

SPLINE Cubic spline data interpolation.
YY = SPLINE(X,Y,XX) uses cubic spline interpolation
to find a vector YY corresponding to XX. X and Y are the
given data vectors and XX is the new abscissa vector.

The ordinates Y may be vector-valued, in which case Y(:,j) is
the j-th ordinate.

PP = SPLINE(X,Y) returns the ppform of the cubic spline
interpolant instead, for later use with PPVAL, etc.

Ordinarily, the not-a-knot end conditions are used. However, if
Y contains two more ordinates than X has entries, then the first
and last ordinate in Y are used as the endslopes for the cubic spline.

Here's an example that generates a coarse sine curve, then
samples the spline over a finer mesh:

x = 0:10; y = sin(x);
xx = 0:.25:10;
yy = spline(x,y,xx);

Here is an example that features a vector-valued spline, along with complete
spline interpolation, i.e., fitting to given end slopes (instead of using
the not-a-knot end condition); it uses SPLINE to generate a circle:

circle = spline( 0:4, [0 1 0 -1 0 1 0; pi/2 0 1 0 -1 0 pi/2] );
xx = 0:.1:4; cc = ppval(circle, xx); plot(cc(1,:), cc(2,:)), axis equal

See also INTERP1, PPVAL, SPLINES (The Spline Toolbox).

Where you can use x as your old time base (old abscissa) and y as your values. Use XX as your new timebase ( e.g. 1:100) and spline will return YY as spline interpolated values at the new abscissa XX.

A similar function schould also exist for quintic spline. Look old biomech-L files. As I remember there was a posting some months ago.

hope I could help,


FROM: Daniel Roetenburg


One of the options is the function:

It resamples the sequence in vector X at P/Q times the original sample rate
using a polyphase implementation. Y is P/Q times the length of X (or the
ceiling of this if P/Q is not an integer). P and Q must be positive
integers. You can choose P and Q for example at 101 points. For N see help
function (I've used N=0).

Good luck.

"M.A.CHEN" schreef:

On Sat, 18 May 2002 13:43:43 +0100 "M.A.CHEN"

> List-members,
> I am doing some measures on gait coordination and have
> written a matlab program that calculates the
> continuous relative phase during the stance phase and/ or
> gait cycle. However i want to produce average
> curves over trials of different time duration,
> therefore i need a time normalization/
> interpolation program so that each trial has an equal
> number of data points.
> Does anybody know of any matlab programs that
> perform this function?
> Cheers,
> Mark.
> ----------------------
> Teaching Assistant
> University of HULL
> M.A.CHEN@psy.hull.ac.uk
> ---------------------------------------------------------------
> To unsubscribe send SIGNOFF BIOMCH-L to LISTSERV@nic.surfnet.nl
> For information and archives: http://isb.ri.ccf.org/biomch-l
> ---------------------------------------------------------------


To unsubscribe send SIGNOFF BIOMCH-L to LISTSERV@nic.surfnet.nl
For information and archives: http://isb.ri.ccf.org/biomch-l