06-20-2012 06:25 PM
Hi,
I want to calculate power spectral density in Labview using y=psd_welch(x,hann(256),128,256,10000);
The result is different from doing y=pwelch(x,hann(256),128,256,10000) in Matlab. What is that problem?
And if I want to do the same job as y=pwelch(x) in Matlab, what code should I use in Labview MathScript structure?
Thank you.
06-21-2012 02:28 AM
Hi,
What's the input signal? Could you please attach a snapshot to show the difference? Thanks!
06-21-2012 03:24 PM
Hi ttrr,
The input signal is sawtooth signal generated by simulate signal, with frequency 100.1hz and sampling rate 10khz.
The first image attached is doing pwelch(x,hann(256),128,256,10000); in matlab, the second one is done by labview.
I want to use labview computing psd for signal showed as picture 3 attached, I already did in Matlab with function pwelch(x).
Now I tried to get the same result in labview, but I failed to find correct codes.
Thanks.
06-21-2012 05:49 PM
Hello pem,
I have a couple questions to clarify your exact situation:
1. What versions of MATLAB and LabVIEW are you working with?
2. Are you intending to run this code on a Real-Time target or a machine that does not have MATLAB installed?
With the second question, a MATLAB script node would call directly into MATLAB from LabVIEW. This would ensure you have exactly the same results. However, you cannot use the MATLAB script node on Real-Time targets and MATLAB needs to be installed on the computer.
Regards,
Andrew Brown
MATLAB® is a registered trademark of The MathWorks, Inc.
06-21-2012 07:20 PM
Hello Andrew,
matlab version is 2011a and labview is 2010. I did run matlab script node without matlab.
If i have matlab installed, may i use it for real time psd calculating?
If not, how to set fft power spectrum and psd vi to get the same result? Thanks.
06-22-2012 11:17 AM
Hey pem,
You can't use the MATLAB Script Node if you plan to deploy your VI to one of our Real-Time targets, like a cRIO or a PXI system. If you are planning to do the calculations on your computer, you'll be fine using the MATLAB Script Node and you can do the calculations on the fly. Can you post your VI for us to look at?
MATLAB® is a registered trademark of The MathWorks, Inc.
06-22-2012 02:41 PM
Hi JtotheB,
VI is attached. What I want to do is to get signal from NI 6220 (or something else), computing power spectral density. Taking some points from psd and calculating.
What I did before is to take signal, and calculate psd in matlab using pwelch. Now I want do all in Labview, any suggestions? Thank you.
06-25-2012 04:39 PM
I use matlab to get psd using pwelch (x); Now I want to get the same result using labview, maybe fft power spectrum and psd vi, how to set it? Thanks
06-26-2012 09:52 AM
Hey pem,
I've been playing with this, and I've got pretty similar results from MathScript to LabVIEW.
I haven't figured out why they're off by that scaling factor (probably units returned by psd_welch), but using the TSA Welch VI from the Advanced Signal Processing Toolkit will allow you to use Welch's method for PSD calculation.
06-26-2012 09:09 PM
Thank you JtotheB, I tried TSA Welch and it did give out the same result as mathscript node, but the both results only gave 103 data of PSD.
When I conputed in matlab, it ran out 129 data. They still cannot match each other. What I want is to get the same PSD value as matlab. Thanks.