Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

psd (MathScript Function) (Windows, Not in Base Package)

LabVIEW 8.5 Help
August 2007

NI Part Number:
371361D-01

»View Product Info

Member of the spectral analysis class.

Syntax

psd(x)

psd(x, nfft, fs, window)

psd(x, nfft, fs, window, noverlap)

psd(x, nfft, fs, window, noverlap, flag)

Pxx = psd(x)

Pxx = psd(x, nfft, fs, window)

Pxx = psd(x, nfft, fs, window, noverlap)

Pxx = psd(x, nfft, fs, window, noverlap, flag)

[Pxx, f] = psd(x)

[Pxx, f] = psd(x, nfft, fs, window)

[Pxx, f] = psd(x, nfft, fs, window, noverlap)

[Pxx, f] = psd(x, nfft, fs, window, noverlap, flag)

Description

Uses the Welch method to estimate the power spectrum density. If you do not specify an output, this function plots the magnitude of the power spectrum in the current plot window.

Details

Examples

Inputs

Name Description
x Specifies the input sequence.
nfft Specifies the length of the FFT to perform on each segment of data. The default is the minimum of 256 and the length of x.
fs Specifies the sampling frequency. The default is 2.
window Specifies the window to apply to x. The length of window must be less than or equal to nfft. The default is a Hanning window with a length of nfft.
noverlap Specifies the number of overlapping data elements between adjacent segments of data. noverlap must be less than the length of window. The default is 0.
flag Specifies the method to use to preprocess x before applying the window. flag is a string that accepts the following values.

'linear' LabVIEW removes the best linear fit of each segment of data.
'mean' LabVIEW removes the mean of each segment of data.
'none' (default) LabVIEW does not preprocess x.

Outputs

Name Description
Pxx Returns the power spectrum of the input signal x. If x is real, the length of Pxx is nfft/2 + 1 for an even nfft and (nfft + 1) / 2 for an odd nfft. If x is complex, the length of Pxx is nfft.
f Returns the frequencies that correspond to Pxx.

Details

This function uses the Welch method to estimate the power spectrum density.

This function is supported in the LabVIEW Run-Time Engine only if you request an output from the function. This function can remain in your scripts when you build a stand-alone application or shared library, but if you do not request an output, the LabVIEW Run-Time Engine does not execute this function. If you request an output, the LabVIEW Run-Time Engine executes this function as normal.

Examples

fs = 1000;
f = 100;
T = 2;
t = 0:1 / fs:T - 1 / fs;
x = sin(2*pi*f*t) + 10*t;
y = sin(2*pi*0.5*f*t) + 20*t;
nfft = 256;
[pxx, fxx] = psd(x, nfft, fs, hanning(nfft), nfft/2, 'linear');

Related Topics

cohere
csd
tfe


Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit