07-13-2005 10:26 AM - edited 07-13-2005 10:26 AM
Message Edited by BiomedGuy on 07-13-2005 10:29 AM
07-15-2005 07:48 AM
Hello Marc,
I have not implemented this before. Still, I have a suggestions and a question that will hopefully help.
First, from the documentation I could find on coherence, you probably want to use
the magnitude returned by CrossPowerSpectrum() for |Gxy( f )|
and
the autoSpectrum returned by AutoPowerSpectrum() for Gxx ( f ) and Gyy ( f ).
Second, should the point by point multiplication in
pResult[i] = ( pMag[i] * pMag[i] ) / (pSignal1[i] * pSignal2[i]);
be a vector product instead? I could be way off the mark with this question.
Regards,
Eric M
07-15-2005 10:16 AM
07-15-2005 11:38 AM
Thanks a lot for replying guys. Eric, I'm not sure if the denominator is a vector product (my theory is a little rusty obviously!) but that might be my problem. I'm going to try the CNIMath routine suggested by Chris, it looks like what I need.
Thanks again, I'll let you know how it goes.
Marc
07-15-2005 02:15 PM
Good call, Chris. The coherence returned by NetworkFunctions looks like it is exactly what you'll need, Mark.
Have a great weekend!
-Eric
07-18-2005 10:34 AM
I have been testing out the NetworkFunctions function. It seems to be giving me a result of 1 for all frequencies no matter what the input. I have tried two sinusoids of exactly the same frequency with and without phase shifts, two different sinusoids and two random signals. I know that without a handle on exactly how my code is organized it dificult to comment, but the function is relatively simple to use and I have debugged all my inputs and outputs to ensure that what I think is there is in fact accurate. Is there some inherent trait of this function that I may be missing? Perhaps in the windowing and / or averaging?
Anything you can think of is much appreciated. Thanks.
Marc
07-21-2005 03:45 PM
The stimulus and response input matrices need to have at least two rows to get non-unity coherence values. This is addressed in the following KnowledgeBase document:
Why is the Network Functions (avg) VI's Coherence Function Output "1"?
The LabVIEW VI noted in the linked document makes the same DLL calls that the Measurement Studio and LabWindows/CVI NetworkFunctions functions call. The main point of this document is that, "If your input arrays contain only one reading (that is, one row of data each), the coherence function will register unity at all frequencies."
Regards,
Eric M
08-08-2005 10:43 AM
Why is the Network Functions (avg) VI's Coherence Function Output "1"?
brought me on the right track! Unfortunately, the described solution (-> the stimulus and response input matrices need to have at least two rows to get non-unity coherence values) doesn't help me much, because I only have one array of stimulus data and one array of response values.
08-09-2005 05:08 PM
Hello Horst,
The Network Functions VI has this requirement because the actual function used to calculate coherence requires an average of two or more readings of the stimulus and response signals for a valid result. The FFT-based Network Measurements section of the Developer Zone document linked in the above KnowledgeBase has more on this.
You could simply split both input arrays, but I recommend being careful how you split them. Ideally, the stimulus would be split into equal length subsets that contain whole periods of the signal. Then, the response would be split into the corresponding subsets. In other words, if the original stimulus has 4 periods of the signal, you could split it into 2 arrays of 2 periods or 4 arrays of 1 period.
Once you do this splitting, the coherence that is calculated by the Network Functions VI will have real meaning.
Regards,
Eric