Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

I have two vectors of matching lengths. They are readings from two different sensors (one is from a smartphone and the other is from a wiimote) of the same hand movement. I am trying to find the time offset between them to synchronise the readings for further processing. The readings I get are of the format (Time(ms) Value) for accelerations in the X,Y and Z direction.

For the synchronization, I plotted the cross-correlation function xcorr2() between the two sets. I am getting the same graph (a weird triangle peak and a straight line at the bottom) for Accelerations along the x, y and z directions (which I guess is good) but I don't know how to interpret it. What do the axes in the graph represent?

Can anyone explain to me what xcorr2() means in a qualitative sense. From the correlation function, how do I determine the offset (i.e. how many seconds is sensor1 behind sensor2)?



share|improve this question
xcorr2 is applied to two matrices (if only one given, it is used in both contexts). How are you using it? That is, how do the x,y,z direction readings become matrices? –  shabbychef Feb 16 '11 at 5:46
add comment

1 Answer

This is an old question so possibly out of date, but here goes anyway:

You should use xcorr rather than xcorr2. Simply do a separate autocorrelation calculation for each of the X, Y and Z sensor axes. Assuming both sensors are equally sampled you can use the peak of the autocorrelation function for a given sensor axis to determine the lag, i.e. the number of samples +/- zero is the lead/lag point.

A simpler, empirical way to examine synchronization with two inertial sensors is to set up a simultaneous recording, hold both sensors together and give a large 'shake'. This will introduce a large impulse in both sensor signals which can be easily used to determine lag.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.