pr10_19.m

来自「Spread Spectrum and CDMA Principles and 」· M 代码 · 共 22 行

M
22
字号
%Problem 10.19;
%OFDM modulation-demodulation;

clear all;
Mc=32; %number of frequencies;
b=2*unidrnd(2,1,Mc)-3; %random bit pattern;
subplot(221);
stairs(b); xlim([1,Mc]); ylim([-1.2,1.2]); xlabel('bit number'); ylabel('source bits'); grid;
DS=5; %channel delay spread;
H=[1,raylrnd(1/sqrt(2),1,DS).*exp(i*2*pi*rand(1,DS))]; %channel delay profile (multipath complex amplitudes);
HF=fft([H,zeros(1,Mc-DS-1)]); %channel transfer function;
ofdm1=ifft(b); %"pure" OFDM symbol;
ofdm=[ofdm1(Mc-DS+1:Mc),ofdm1]; n=Mc+DS; %OFDM symbol with prefix;
subplot(222);
bar([0:Mc+2*DS-1],[abs(ofdm),zeros(1,DS)],0.2); xlim([0,Mc+2*DS-1]); xlabel('t/T_{b}'); ylabel('in OFDM sym'); %plotting transmittd OFDM symbol;
chout=filter(H,1,[ofdm,zeros(1,DS)]); %signal at the channel output;
subplot(224);
bar([0:Mc+2*DS-1],abs(chout),0.2); xlim([0,Mc+2*DS-1]); xlabel('t/T_{b}'); ylabel('out OFDM sym'); %plotting output signal;
dmod1=fft(chout(DS+1:n)); %demodulated OFDM symbol after dropping prefix;
dmod=dmod1./HF; %zero-forcing equalizing;
subplot(223);
stairs(sign(real(dmod))); xlim([1,Mc]); ylim([-1.2,1.2]); xlabel('bit number'); ylabel('demodtd bits'); grid;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?