-1
$\begingroup$

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!

  • 0
    you **may** be able to get a$n$swers at http://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.2011-03-10

1 Answers 1

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.