LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab code

Can anyone tell me these matlab codes have the same algorithm as which vi?
 
w and x are signals
 
pww=psd(w,256*16,1000,256*16)
pxx=psd(x,256*16,1000,256*16)
pwx=csd(w,x,256*16,1000,256*16)
 
in any case i need the return values in complex number.
 
 
0 Kudos
Message 1 of 6
(3,377 Views)
I have tried using the FFT spectrum(real and im).vi / power spectrum(real and im).vi and cross spectrum(real and im).vi but they do not give the same complex number as my matlab code. i am trying to calculate the coherence between say 3 signals.
Any idea where went wrong? 
0 Kudos
Message 2 of 6
(3,356 Views)

HI Celynn,

 

I tried the MATLAB commands you mentionedf in your post witha  simple signal like x=[0 1 2 3 5] . Both the psd and csd commands return real arrays. However from your post it appears that you are getting complex arrays as outputs in MATLAB. Can you please clarify.

Ankita 

0 Kudos
Message 3 of 6
(3,340 Views)
Thanks for your help.
 
When i run matlab psd code it return real values and for matlab csd it return complex values (due to the difference in the 2 signals phase). 
So the in LV i tried run the signals using FFT spectrum.vi(real and im) and FFT cross spectrum.vi(real and im). it return different values from Matlab. So i reckon some of the parameters like window or averaging was not defined properly.
Attached is my vi.  
0 Kudos
Message 4 of 6
(3,338 Views)
Hi Celynn,
 
I see what you are saying. I tried using psd function in Matlab and FFT power spectral  density .vi in LV but ended up with different results.
I would suggest that you use FFT.VI in LabVIEW and compare it with FFT function in Matlab. You should see similar results from both the software. Only thing to remember is that arrays in Matlab are one-based while in  LabVIEW they are zero-based. Now build your power spectrum by taking the square of magnitude of fft. This way you should see similar results between LabVIEW and Matlab.
On my end, I will report this issue to R&D department and once we have found a resolution, I will post it on this thread.
 
Thanks,
Ankita
0 Kudos
Message 5 of 6
(3,311 Views)

Ankita, then between how do i proceed to calculate the PSD after i get my power spectrum in Labview?

According to the formula PSD = power spectrum in Vrms^2 /( freq resolution X noise power bandwidth of window) 

is it correct to divide with the frequency resolution x 1.5 (if i am using hanning window) for each element? does it applies to the same for CSD? with the cross spectrum again i repeat as mention in the above?

 

0 Kudos
Message 6 of 6
(3,287 Views)