?? ofdm1.m
字號:
clear;clc;
para=64;
fftlen=128;
noc=128;
nd=6;
m1=2;
sr=250000;
br=sr.*m1;
gilen=32;
nloop=10;
noe=0;
nod=0;
eop=0
nop=0
ebn0_min=1
ebn0_max=20
ebn0=ebn0_min:1:ebn0_max
len_ebn=length(ebn0)
for j=1:len_ebn
ebn0=j
for i=1:nloop
seldata=rand(1,para*nd*m1)>0.5
paradata=reshape(seldata,para,nd*m1)
[ich,qch]=qpskmod(paradata,para,nd*m1)
kmod=1./sqrt(2)
ich1=ich.*kmod
qch1=qch.*kmod
x=ich1+qch1.*sqrt(-1)
y=ifft(x)
ich2=real(y)
qch2=imag(y)
[ich3,qch3]=giins(ich2,qch2,fftlen,gilen,nd)
fftlen2=fftlen+gilen
spow=sum(ich3.^2+qch3.^2)/nd./para
attn=0.5*spow*sr/br*10.^(-ebn0/10)
attn=sqrt(attn)
[ich4,qch4]=comb(ich3,qch3,attn)
[ich5,qch5]=girem(ich4,qch4,fftlen2,gilen,nd)
rx=ich5+qch5.*sqrt(-1)
ry=fft(rx)
ich6=real(ry)
qch6=imag(ry)
ich7=ich6./kmod
qch7=qch6./kmod
[demodata]=qpskdemod(ich7,qch7,para,nd*m1)
demodatal=reshape(demodata,1,para,nd*m1)
noe2=sum(abs(demodatal-seldata))
nod2=length(seldata)
noe=noe+noe2
n=nod+nod2
if noe2~=0
eop=eop+1
else eop=eop
end
eop
nop=nop+1
end
per=eop/nop
ber=noe/nod
fprintf('%d\t%d\t%d\t%e\n',ebn0,noe,nod,ber)
x1(j)=ber
end
end
ebn0=ebn0_min:1:ebn0_max
figure(1) subplot(221) plot(ich2,'k-.')
title('OFDM子載波采用QPSK調制方式的I-channel的信號')
xlabel('Time')
ylabel('Amplitude')
grid on
subplot(2,2,2)plot(qch2,'r-.')
title('OFDM子載波采用QPSK調制方式的Q-channel的信號')
xlabel('Time')
ylabel('Amplitude')
grid on
figure(2)subplot(2,1,1) plot(ich7,qch7,'b.')
title('OFDM子載波采用QPSK調制方式的解調相位')
xlabel('Ichannel(g)')
ylabel('Q chan-ne1')
grid on
figure(3) subplot(2,1,1)
title('OFDM子載波采用QPSK調制方式的仿真誤碼率')
semilogy(ebn0,xl,'*')
xlabel('E/N dB') ylabel('BER')
grid on
hold on
legend('OFDM子載波采用QPSK調制方式的仿真誤碼率')
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -