Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have values from two sensors stored in two vectors A and B. They both represent values of the sensors at times TA and TB which is stored in two other vectors(since it is not uniform sampling) Both A and B represent the same data but A is shifted a bit to the right because of the delay in starting the sensors.

My question is, how do I calculate this delay and more importantly, how do I shift A to match B or vice versa, such that I can do a one-to-one correspondence of the data?

Right now, I am finding the peak of the cross-correlation function of A and B to find the offset (in number of samples, not time) and padding the arrays with zero upto that number, but I am 100% sure that is wrong. Problem is, I don't know how else.

PLEASE help!

Thanks!

share|improve this question
    
you may be able to get answers at stats.stackexchange.com if you don't receive one here. Though I must say, as currently worded, I am not entirely sure whether your problem is one about data analysis or one about matlab. –  Willie Wong Mar 10 '11 at 18:52

1 Answer 1

Check out the xcorr function in MATLAB, found here: http://www.mathworks.com/help/toolbox/signal/ref/xcorr.html

It is equivalent to "matched filtering", which is convolving some vector (input 1) with a time reversed, complex-conjugated pattern vector (call the pattern vector input 2). A peak will occur at the index where the maximum overlap occurs between input 1 and input 2.

share|improve this answer

Your Answer

 
discard

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