Powerspectraldensity MATLAB
Powerspectraldensity MATLAB
dspdata.psd
Power spectral density
Syntax
Hpsd=dspdata.psd(Data)
Hpsd=dspdata.psd(Data,Frequencies)
Hpsd=dspdata.psd(...,'Fs',Fs)
Hpsd=dspdata.psd(...,'SpectrumType',SpectrumType)
Hpsd=dspdata.psd(...,'CenterDC',flag)
Description
The power spectral density (PSD) is intended for continuous spectra. The integral of the PSD over a given frequency band computes
the average power in the signal over that frequency band. In contrast to the mean-squared spectrum, the peaks in this spectra do
not reflect the power at a given frequency. See the avgpower method of dspdata for more information.
A one-sided PSD contains the total power of the signal in the frequency interval from DC to half of the Nyquist rate. A two-sided PSD
contains the total power in the frequency interval from DC to the Nyquist rate.
Hpsd = dspdata.psd(Data) uses the power spectral density data contained in Data, which can be in the form of a vector
or a matrix, where each column is a separate set of data. Default values for other properties of the object are shown below:
SpectrumType 'Onesided' Nyquist interval over which the power spectral density is
calculated. Valid values are'Onesided' and
'Twosided'. A one-sided PSD contains the total signal
power in half the Nyquist interval. See the onesided
and twosided methods in dspdata for information on
changing this property.
Hpsd = dspdata.psd(Data,Frequencies) uses the power spectral density estimation data contained in Data and
Frequencies vectors.
Hpsd = dspdata.psd(...,'Fs',Fs) uses the sampling frequency Fs. Specifying Fs uses a default set of linear
frequencies (in Hz) based on Fs and sets NormalizedFrequency to false.
Hpsd = dspdata.psd(...,'CenterDC',flag) uses the value of flag to indicate whether the zero-frequency (DC)
component is centered. If flag is true, it indicates that the DC component is in the center of the two-sided spectrum. Set the
flag to false if the DC component is on the left edge of the spectrum.
Methods
avgpower
centerdc
normalizefreq
onesided
plot
twosided
For example, to normalize the frequency and set the NormalizedFrequency parameter to true, use
Hpsd = normalizefreq(Hpsd)
For detailed information on using the methods and plotting the spectrum, see the dspdata reference page.
Examples
Estimate the power spectral density of a noisy sinusoidal signal with two frequency components and then store the results in a PSD
data object and plot it.
Fs = 32e3;
t = 0:1/Fs:2.96;
x = cos(2*pi*t*1.24e3)+ cos(2*pi*t*10e3)+ randn(size(t));
nfft = 2^nextpow2(length(x));
Pxx = abs(fft(x,nfft)).^2/length(x)/Fs;
See Also