LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Specgram and Power Spectral Density differences

Hello....

I used to perform spectral analysis through the Specgram function of Matlab, but now I am trying to perform the same analysis with the Power Spectral Density function of Labview. But the values obtained by the two methods are not exactly the same.

The values obtained from Power Spectral Density of Labview are 1000 fold lower AND a little bit different from that obtained from Specgram function of Matlab. This small difference is only observed when the values are analyzed in absolute values. When they are analyzed in normalized values (%), the results obtained from Labview and Matlab are the same. Anyone have a idea to explain this small difference in the absolute values?

In both situations, Matlab and Labview, the whole data is splitted in segments of 512 points, overlapped by 50 %, and each one of these segments are submitted to spectral analysis.

Thank you very much for attention and help

Attached is:

- a example data file to be loaded in the VI
- a result file from Labview and a result file from Matlab, obtained from the example data
- The VI
- the sequence of commands that I used to use with the specgram function in Matlab

Thanks

Dan07


Message Edited by dan07 on 07-09-2008 10:45 AM
0 Kudos
Message 1 of 3
(2,625 Views)

Hello friend, Smiley Very Happy

 

I analyzed your case and I suggest you to test it using mathscrip in LabVIEW. There are two possibilities to do it. The first is using LabVIEW MathScript, like is described in these two pages below.

http://zone.ni.com/devzone/cda/tut/p/id/3502

http://zone.ni.com/devzone/cda/tut/p/id/3257

Other possibility is use the VI “MATLAB scrip” that is located in Mathematics -> Script & Formulas -> Script Node -> MATLAB scrip, searching in block diagram’s tools pallet. Or use MathScript Node located in Mathematics -> Script & Formulas -> MathScript Node. There are some examples in LabVIEW help.

 

There are many possibilities to explain why this difference can be occurring. Are you sure that your program is correct in LabVIEW and in Matlab? Are they really doing the same thing? I verified in Specgram.txt (that you sent us) you are using a parameter pi, but this parameter is not present in your program in LabVIEW. Is this parameter is really present in your program?  Is this parameter is really correct? The Marhworks page shows this parameter called A like a vector (http://www.mathworks.com/access/helpdesk_r13/help/toolbox/signal/specgram.html).

Do you know what is the B output unit used by Matlab? The output magnitude unit used by LabVIEW is Vrms²/Hz.

 

Please, check these comments above.

 

Best regards.

 

Bruno M.

0 Kudos
Message 2 of 3
(2,577 Views)
Hello Bruno, how  are you?

I checked up all your comments and solved my problem by using the specgram of Labview. The codes were not accurately the same, I made some mistakes in the Labview code and the result was different by this reason.

Now everything is going well.

Thanks for attention and help

Dan07
0 Kudos
Message 3 of 3
(2,526 Views)