LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Would someone check my vi

Hi,
I am trying to calculate the coherence between 3 signals instead of 2 signals. 
I divide my data to 10 blocks of 4096 to pass through the FFT power spectrum.vi and cross power spectrum.vi and calculate the coherence. The results obtain is not between 0 to 1 and is alot greater than 1.
Please advise my mistakes.
 

Message Edited by celynn on 09-26-2005 02:34 AM

Message Edited by celynn on 09-26-2005 02:35 AM

0 Kudos
Message 1 of 9
(3,795 Views)
Hello,
 
I presume you mean the coherence function defined as the ratio of the output power caused by the input signal to the input signal power.  I am not certain what's going wrong in your VI, but if you can post the expression you are using to compute it, with definitions of all symbols used in that expression, we can begin to take a look at things more closely.
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 2 of 9
(3,743 Views)

Hi, This problem have been bugging me for sometimes. It seems straight forward, based on the coherence function formulation for 2 signals instead now i am calculating the coherence for 3 signals.  

I have redefined the expression in the attached file.

 

Message Edited by celynn on 09-27-2005 11:27 PM

0 Kudos
Message 3 of 9
(3,723 Views)

Hello,

You indicated the following definition for the coherence function, which appears to be defined for two signals:

coherence function=  Mag  (Avg SAB(f)^2)
                                      --------------------------
                                     Avg SAA(f). Avg SBB(f)

 

You then defined Ans 2 (which seems to be your matrix expression for a 3 signal coherence function) as:
 
                     [Pyw;Pzw]*inv[Pyy Pyz; Pzy Pzz][Pyw;Pzw]
  Ans 2 =      ----------------------------------------------------------  where,
                                                   [Pww]
"Pyw is the cross power of y and w signals.
Pzw is the cross power  of z and w signals
Pyz is the cross power  of y and z signal.
Pyy is the power spectral  of y signal.
Pzz is the power spectral of z signal.
Pww is power specrtal of w signal."
 
 
Your code produces Ans 2 as a 2D Array - is this the coherence calculation for 3 signals?  In your previous post, you indicated that you expect a scalar, specifically between 0 and 1, and were troubled by not obtaining consistent results.  Where is the number you compute that represents the coherence function for 3 signals?
 
Since I am not familiar with the computation, you'll have to very clearly define what the coherence of 3 signals is, and which output of your VI represents this.  At that point, you should be able to look through your code step by step, and determine if indeed it implements the function you desire.  If you have not already, you can right click on various wires in your algorithm and choose a). "Probe" and/or b). "Set Breakpoint" in order to a). view data for the wire and/or b). stop execution when your code reaches that point.
 
I hope this discussion helps you clarify your problem, or helps you to use some of the debugging features in LabVIEW.  At this point, however, I do not think the problem has been fully defined.  Although this may be sufficient for someone familiar with the computation, it may not be for those of us attempting to help from outside the world of 3 signal coherence computations.
 
Repost and I'll try to help you if you can very specifically define all expressions, and components of those expressions down to a fundamental level.
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 4 of 9
(3,697 Views)

Hi JLS,

Attached is a modified network function.vi i tries to use to calculate the multiple coherence of the 3 signals. Hope you can understand what i am trying to do here. To calculate the multiple coherence is straight forward like calculating the coherence. It makes use of the power spectrum and cross power spectrum to do the calculation. The only difference is in the expandsion in maths which i have illustrated.

In the previous post, my multiple coherence value is in the "ans2" which becomes a 2D due to the matrix calculation, so ultimately i will index the 1st row array as my final answer. Sorry about the confusion. 

Let me know if i need to illustrate more.

 

0 Kudos
Message 5 of 9
(3,673 Views)
Hello,
 
I don't think the modified VI was attached for some reason, can you try attaching it again?
 
Thanks,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 6 of 9
(3,647 Views)
Hi JLS,
Oops how careless i am.
Thanks.
0 Kudos
Message 7 of 9
(3,633 Views)
Hi JLS,
Attached is my sampled data in txt you have to open using Matlab program in order to get 4 columns of data. You can pass these data into my program coherence 3 and see the result. The coherence graph is ok but the multiple coherence give 0 to 14. I have used Matlab to create the multiple coherence and attached is the graph from Matlab.

Message Edited by celynn on 10-05-2005 01:16 PM

Download All
0 Kudos
Message 8 of 9
(3,612 Views)
Hello,
 
Ok, I suspect you may be simply seeing the effects of computation errors.  More specifically, it looks like you define the coherence function in part using an expression like |averaged Sxy(f)|^2.  I think I see where you attempt to implement this in your code, however, I think you do so by simply squaring the real part.  The magnitude defined over the complex numbers is |a+bi| = sqrt(a^2 + b^2).  So unless your complex values are purely real, then squaring the real part is not equal to squaring the magnitude of the complex number.
 
Try attaching the coding by using your expressions as guides for defining subVIs.  Make your top level VI be simple computations or ratios of other components you compute.  Then write each subVI and test it carefully to make sure it computes it's part of the expression correctly.  I think you may simply have a couple problems interpreting your expressions (such as the case noted above), and need to more carefully code your desired functionality.  Also, by modularizing your code logically this way, it will make it easier to see which part of the computation you are performing in a given place.
 
It should be pretty quick for you to run through your code to check if other similar issues exist, and it may just fix the problem!
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 9 of 9
(3,591 Views)