c8_welchp.m
来自「通信系统仿真原理与无线应用书中matlab源程序」· M 代码 · 共 26 行
M
26 行
% File: c8_welchp.m
% Software given here is to accompany the textbook: W.H. Tranter,
% K.S. Shanmugan, T.S. Rappaport, and K.S. Kosbar, Principles of
% Communication Systems Simulation with Wireless Applications,
% Prentice Hall PTR, 2004.
%
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 + -
显示快捷键?