LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cross correlation

Hello!

I'm trying to use the cross correlation .vi, but I'm dealing with some problems...

I already searched and read other threads about this subject in the forum, but I'm not being able to get rid of my problems.

I'm trying to calculate the cross-correlation of 2 arrays and get as result a graph with the cross-correlation coefficients for each slide of one array relative to the other (a kind of oscillatory waveform with one higher peak possibly and desirably over 0.8 when the 2 arrays are well correlated). But I always get a "triangle"  result, with scales varying between 0 and  values >>2E+8 Smiley Sad

I searched the web and found a C source code for performing what I want, and I implemented it in Labview. I attached my .vi so that you could see what I did, and help me because sometimes it gives me values of cross-correlation higher than 1 Smiley Sad

The site with the C source code and explanation is in the following adress: http://astronomy.swin.edu.au/~pbourke/other/correlate/

I hope you understand what my question is, and I would be greatly pleased with some good help on this.

I don't know if it's possible to achieve what I want using only labview already made .vi's (which I suppose, would be better and faster processing), or if it would be better to try to make  a .vi by miself such as the one I send in attachment.

Thanks in advance!


Message Edited by Goju-Ryu on 05-17-2006 06:46 AM

0 Kudos
Message 1 of 7
(3,441 Views)
Any help? Smiley Sad

Is there something I should try to explain better, so you could help me more easily?
0 Kudos
Message 2 of 7
(3,413 Views)
I cannot answer all your questions, but I may be able to help on some. I compared your result with the NI_AALPro.lvlib.CrossCorrelation.vi (LV8) and was able to get very similar, but not exactly equal results. I used a very simple triangular pulse as an input.

Rather than connecting directly to the raw data, I connected the input to the Input - Mean array. I selected biased normalization.

I looked at your implementation of the algorithm. The style guides recommend left to right dataflow (wiring) as much easier to follow. I think you could use For loops with autoindexing rather than the while loops and the comparison to the length of the array. Also it is good practice to initialize an arrray outside the loop, pass it into the loop via a shift register, and use Replace Array Subset inside the loop rather than using the Build Array primitive.

Lynn
0 Kudos
Message 3 of 7
(3,411 Views)
johnsold, I followed your instructions, and the results present a "waveform" as I expected, but there's still a problem. The amplitude of the results should be between -1 and 1, but they're between -100 and 300 (for instance...).

My intention is to perform a cross-correlation between 2 arrays, and get a high cross-correlation value (the maximum value of the returned array of cross-correlation .vi) (next to 1 or -1) , when the 2 arrays are quite similar at a certain segment of their length, and get low cross-correlation values (next to 0), when they're quite different all over their extention.

...
0 Kudos
Message 4 of 7
(3,405 Views)
Can you post some typical data? Either a tab-delimited text file or a VI with the data saved as the default value of a control will work well.

Lynn
0 Kudos
Message 5 of 7
(3,389 Views)
Here are 3 txt files with some typical data.

dir1 and dir2 should be high correlated (dir1 is similar to dir2 to some extent ), while  cross-correlation with the 2 files before and esq should be weak.


Thank you very much for your kind help! 😉

Download All
0 Kudos
Message 6 of 7
(3,383 Views)
hi
Why not using a C calcul box in Labview and copy the code given??

Kamal
NIF
0 Kudos
Message 7 of 7
(3,363 Views)