LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Compare arrays

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

 

 

0 Kudos
Message 1 of 13
(4,020 Views)

Can you attach a VI with some typical sample data?

0 Kudos
Message 2 of 13
(4,017 Views)
I don't have a vi since I don't know how to do it. But I think that it needs some kinds of fitting algorithms. An example plot is attached.
0 Kudos
Message 3 of 13
(4,001 Views)

Note that the peak detection algorithm does not work here.

0 Kudos
Message 4 of 13
(3,995 Views)

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)


"Should be" isn't "Is" -Jay
Message 5 of 13
(3,958 Views)
Bit hard to tell from the data, but it seems to be as if cross-correlation is what you want to do here. There's a LabVIEW function (not in the Base package) that does cross-correlation.
Message Edited by smercurio_fc on 04-06-2009 01:52 PM
Message 6 of 13
(3,952 Views)

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?

Message 7 of 13
(3,939 Views)
Here is two test data.
0 Kudos
Message 8 of 13
(3,924 Views)

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.

 

 

 

 

Message Edited by altenbach on 04-06-2009 01:25 PM
Download All
Message 9 of 13
(3,911 Views)

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

0 Kudos
Message 10 of 13
(3,898 Views)