c8_welchp.m
来自「经典书籍《通信系统仿真原理与无线应用》chap8部分课后题仿真源代码」· M 代码 · 共 21 行
M
21 行
% File: c8_welchp.m
fs = 16;
x = random_binary(1024,fs)+i*random_binary(1024,fs);
for nwin=1:4
nwindow = nwin*1024;
[pxx,f] = pwelch(x,nwindow,fs);
pxx = pxx/sum(sum(pxx));
n2 = length(f)/2;
pxxdB = 10*log10(pxx/pxx(1));
ptheory = sin(pi*f+eps)./(pi*f+eps);
ptheory = ptheory.*ptheory;
ptheorydB = 10*log10(ptheory/ptheory(1));
subplot(2,2,nwin)
plot(f(1:n2),pxxdB(1:n2),f(1:n2),ptheorydB(1:n2))
ylabel('PSD in dB')
xx = ['window length = ',num2str(nwindow)];
xlabel(xx)
axis([0 8 -50, 10]); grid;
end
% End of script file.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?