功率谱密度(Power Spectral Density,简称PSD):单位为V**2/Hz
功率谱(’specturm‘): 单位V**2
matlab中周期图法periodogram计算功率谱密度和功率谱详解:
1、功率谱密度计算(spectrumtype='psd')
fs = 1000;
t = 0:1/fs:5;
x = cos(2*pi*100*t) + randn(size(t));
N = length(x);
%psd计算
xdft = fft(x);
U = rectwin(N)'*rectwin(N);
sxx = (1/(U)) * abs(xdft).^2;%双边谱(加窗时N对应U = win1'*win1,对于矩形窗正好等于数据长度;参考函数computeperiodogram)
% Generate the one-sided spectrum [Power](参考函数computepsd)
freq = 0:fs/N:fs/2;
if mod(N,2)==0
sxx = sxx(1:N/2+1);
sxx(2:end-1) = 2*sxx(2:end-1);
else
sxx = sxx(1:(N + 1)/2);
sxx(2:end) = 2*sxx(2:end);
end
% Compute the PSD [Power/freq]
pxx = sxx./fs; % Scale by the sampling frequency to obtain the psd
2、功率谱计算(spectrumtype='power')
%power计算
xdft = fft(x);
U = sum(rectwin(N))^2;
sxx = (1/(U )) * abs(xdft).^2;%双边谱(U参考函数computeperiodogram))
% Generate the one-sided spectrum [Power]
freq = 0:fs/N:fs/2;
if mod(N,2)==0
sxx = sxx(1:N/2+1);
sxx(2:end-1) = 2*sxx(2:end-1);
else
sxx = sxx(1:(N + 1)/2);
sxx(2:end) = 2*sxx(2:end);
end
3、比较
(1)计算功率谱密度(U = rectwin(N)'*rectwin(N);)和功率谱(U = sum(rectwin(N))^2;)时归一化参数U不同
(2)功率谱密度需要除以采样率fs
(3)功率谱密度/功率谱 =(sum(rectwin(N))^2 )/(rectwin(N)'*rectwin(N)*fs) 比值恒定
clear;clc;close all
rng default
fs = 1000;
t = 0:1/fs:2;
x = cos(2*pi*100*t) + randn(size(t));
N = length(x);
[pxx_power,f] = periodogram(x,[],N,fs,'power');
[pxx_psd,f] = periodogram(x,[],N,fs,'psd');
figure
plot(pxx_power, 'r')
hold on
plot(pxx_psd,'k')
legend('power','psd')
figure
plot(pxx_psd./pxx_power)