Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

psd (MathScript RT Module Function)

LabVIEW 2012 MathScript RT Module Help

Edition Date: June 2012

Part Number: 373123C-01

»View Product Info
Download Help (Windows Only)

Owning Class: spectral analysis

Requires: MathScript RT Module



psd(x, fftsize, fs, window)

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

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

Pxx = psd(x)

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

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

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

[Pxx, f] = psd(x)

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

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

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


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.




Name Description
x Specifies the input sequence.
fftsize 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 fftsize. The default is a Hanning window with a length of fftsize.
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.


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


This function is similar to the psd_welch function. However, there are some slight differences between the two functions, such as different formulas and different default values for the inputs. National Instruments recommends you use the psd_welch function instead of the psd function.

The following table lists the support characteristics of this function.

Supported in the LabVIEW Run-Time Engine Yes (if you request output)
Supported on RT targets Yes (if you request output)
Suitable for bounded execution times on RT Not characterized


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;
fftsize = 256;
[pxx, fxx] = psd(x, fftsize, fs, win_hann2(fftsize), fftsize/2, 'linear');

Related Topics



 Was this document helpful?  submit
  Helpful Not Helpful