LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

finding maximum correlation coefficient

Solved!
Go to solution

Hi,

 

I'm measuring 2 analog signals simultaneously from the 9233 DAQ module.

 

Whenever there is a trigger, my DAQ will collect an X number of samples from the analog module and perform a cross correlation analysis on the data.

 

My question is how can i get the maximum cross correlation coefficient between the two signals (e.g. North is my reference, how many samples do i need to shift my South to get the maximum correlation coefficient)?

 

My purpose for this?

This is so that i can get the delay between the two samples (e.g.sampling at 50kHz, if i need to shift the sample 300 times, then i know my delay is 300*1/50000 = 6ms)

 

 Thank you.

 

Attached a picture of my waveforms

North = My reference signal

South = My 2nd signal

Bottom = Corss correlation betwen the two signals

0 Kudos
Message 1 of 10
(7,366 Views)
Can't you use the Max/Min function in the Array pallete to find the maximum coefficient and its location?  If this isn't the correct value, then you might want to truncate your reference signal to keep only the part that will match best (like the first 0.003 seconds of data).
Randall Pursley
Message 2 of 10
(7,341 Views)

Hi Randall,

 

Appreciated your input but i think you misunderstood my question a little bit. I wasn't trying to look for the peak in the cross correlation graph which I think you thought I was. Actually what i'm looking for is the maximum correlation coefficient between the 2 signals.

 

I have simulated an example to better put my question across. As illustrated in my attachment, i have 2 signals, the 1st is always delayed by 50s while the delay of the second signal varies from 110s to 50s.

 

When the delay of both signals are at 50s, we have the maximum correlation coefficient of 1.000 as both signals are now in sync.

 

So what i am trying to do now is to reverse this process so that i can find the delay between my two signals by finding out how many shifts do i need to make on my 2nd signal to get the maximum correlation (note: does not have to be 1.000, just as long as it is the highest possible value between these 2 sets of data).

 

Anyone who has a good idea on how to do this please feel free to post.

 

Thanks alot!

 

 

0 Kudos
Message 3 of 10
(7,322 Views)
Solution
Accepted by topic author Carefree

I'm pretty sure the maximum value of the cross correlation function will correspond to the location of the highest correlation coefficient.  Use  your own example to verify this.

 

Find the index of this value.  Subtract the size of the reference signal (in the X input) from the index of the peak value.  The resulting value should be the number of points that equates to the shift.  Divide this value by your sampling rate (50,000 in your case) and you should have your answer.

Message Edited by rpursley8 on 03-31-2009 09:41 AM
Randall Pursley
Message 4 of 10
(7,302 Views)

Really? Okay I will try that once I get the chance to.

 

You've been a great help Randall. Thanks!

0 Kudos
Message 5 of 10
(7,286 Views)

Is this the solution you proposed Randall?

 

If i was taking 200 samples for my reference, i substract it from the max index and multiply the resultant value with my sample time (1/50kHz) to get the delay?

0 Kudos
Message 6 of 10
(7,263 Views)
That sounds right.  Does the answer appear to be right when applied to real data?
Randall Pursley
0 Kudos
Message 7 of 10
(7,232 Views)

It does work to some extend if the signals are matching but once in awhile the value does go astray due to the second signal's waveform discrepancies when compared to the refence waveform. But when i applied it to two generated signals which were alike, the method does hold.

 

Thanks again Randall.

0 Kudos
Message 8 of 10
(7,215 Views)
That's why you might want to truncate your reference signal to the part of the waveform that will consistently be similar to the other one.  You might also try filtering it to focus on some primary components of the signal before the correlation.
Randall Pursley
0 Kudos
Message 9 of 10
(7,201 Views)

Hello everyone!!

I am new to Labview!!!

 

I have a situation where I have an array with each row representing a code (see picture attached). I have to find the correlation between each of these codes (rows of the array). Could anyone please suggest any ideas how I could do this in labview.

Any help would be greatly appreciated:)

0 Kudos
Message 10 of 10
(6,933 Views)