http://www.ilovematlab.cn/thread-218001-1-1.html
http://www.ilovematlab.cn/thread-52799-1-1.html
http://www.ilovematlab.cn/thread-327632-1-1.html
你的版本是什么?从R2013a开始,建议用pwelch,在那之前,建议用spectrum.welch
形状上没啥差异,无非是缺省用的窗不一样,但是这个pwelch的结果没有除采样率
fs = 1000;
t=0:1/fs:1;
y=cos(2*pi*40*t)+3*cos(2*pi*100*t)+randn(size(t));
nfft = 2^nextpow2(length(y));
subplot(3, 1, 1);
Hs=spectrum.welch;
hpsd = psd(Hs, y,'NFFT',nfft,'Fs',fs);
Pw = hpsd.Data;
Fw = hpsd.Frequencies;
plot(Fw, Pw)
grid;axis([0 500 0 max(Pw)]);title('psd');
subplot(3, 1, 2);
[Pxx,fxx]=pwelch(y,[],[],[],fs,'twosided');
plot(fxx, Pxx);
grid;axis([0 500 0 max(Pxx)]);title('pwelch');
subplot(3