04-06-2009 11:05 AM
Hi Everyone,
I have two same size 1D arrays, one is reference and another is data. The two arrays have similar patterns but shifts (not constant). The question is:
How can I change the index values of the data array such that it matches the ref array in labview?
In other words, assume y and x are the indexes of data and ref arrays.
I would like to find values of a, b, c for
y = ax^2 + bx +c ,
such that
data array - ref array ~ 0
Thanks,
Paul
04-06-2009 11:09 AM
Can you attach a VI with some typical sample data?
04-06-2009 11:50 AM
04-06-2009 11:56 AM
Note that the peak detection algorithm does not work here.
04-06-2009 01:40 PM
Shenp,
Sounds like a good place for a "brute force" method since the data cannot be synchonized otherwise.
solve the mean of y(0:n)-x(0:n) for x shifted by 0-n. the lowest mean is your best fit. (Give the work to the processor- its bored)
04-06-2009 01:47 PM - edited 04-06-2009 01:52 PM
04-06-2009 02:09 PM
Cross correlation will easily solve the linear shift issue, but from the problem description it seems that there is a quadratic distortion to the x-values. That seems more complicated.
If I read this correctly, it might mean x1 = ax2^2 + bx2 +c. This would need a nonlinear remapping using interpolation, for example.
shenp: Can you at least attach a datafile, e.g. text with two columns?
04-06-2009 02:42 PM
04-06-2009 03:22 PM - edited 04-06-2009 03:25 PM
A simple crosscorrelation to figure the linear shift seems to be sufficient. Try the following rough draft (LV 8.5):
A picture of the code (of course you want to shift instead of rotate, but this should get you started):
A picture of the difference between the two signals before and after alignment.
04-06-2009 04:09 PM
altenbach,
Thank you very much for your help. It is a good start point although a constant or linear shift is not good enough for my application. A nonlinear fitting process should be applied.
Paul