?? ofdm2.m
字號(hào):
%ofdm2.m
%16QAM調(diào)制、AWGN信道下的仿真程序
%***************************variables********************************
para = 52;%并行信道數(shù)
fftlen = 64;%FFT長度
noc = 52;%載波數(shù)
nd = 3;%每個(gè)仿真循環(huán)的OFDM數(shù)
m1 = 4;%調(diào)制水平:QPSK
gilen = 16;%保護(hù)間隔長度
ebn0 = 2;%信噪比
sr = 250000;%OFDM symbol rate (250k syombol/s)
br = sr.*m1;%bit rate per carrier
%**************************主循環(huán)部分*********************************
nloop = 200;%仿真的循環(huán)數(shù)
noe1 = 0;%信道解碼前錯(cuò)誤數(shù)據(jù)數(shù)
nod1 = 0;%信道解碼前傳輸數(shù)據(jù)數(shù)
%*************************發(fā)射機(jī)**************************************
for iii = 1:nloop
%****************************數(shù)據(jù)產(chǎn)生******************************
xx = ones(1,para*nd*m1);
%**************************串并轉(zhuǎn)換*********************************
paradata = reshape(xx,para,nd*m1);
%************************16qam調(diào)制**********************************
[ich,qch] = qammod2(paradata,para,nd,m1);
%數(shù)據(jù)映射
[ich1,qch1] = cramapping(ich,qch,fftlen,nd);
%*******************************IFFT********************************
x = ich1 + qch1.*i;
y = ifft(x);
ich2 = real(y);
qch2 = imag(y);
%**************************插入保護(hù)間隔******************************
[ich3,qch3] = giins1(ich2,qch2,fftlen,gilen,nd);
fftlen2 = fftlen + gilen;
%**************************attenuation calculation*********************
spow = sum(ich3.^2+qch3.^2)/nd./para;
attn = 0.5*spow*sr/br*10.^(-ebn0/10);
attn = sqrt(attn);
%**************************AWGN addition******************************
[ich4,qch4] = comb(ich3,qch3,attn);
%**********************去除保護(hù)間隔***********************************
[ich5,qch5] = girem1(ich4,qch4,fftlen2,gilen,nd);
%*************************FFT*****************************************
rx = ich5 + qch5.*i;
ry = fft(rx);
ich6 = real(ry);
qch6 = imag(ry);
%載波逆映射
[ich7,qch7] = crdemapping(ich6,qch6,fftlen,nd);
%******************************解調(diào)**********************************
[demodata] = qamdemod2(ich7,qch7,para,nd,m1);
%*****************************并串轉(zhuǎn)換*******************************
demodata1 = reshape(demodata,1,para*nd*m1);
%****************************bit error rate(BER)*********************
noe10 = sum(abs(demodata1 - xx));
nod10 = length(xx);
noe1 = noe10 + noe1;
nod1 = nod10 + nod1;
fprintf('%d\t%e\t\n',iii,noe10/nod10);
end
ber1 = noe1/nod1;
%********************************輸出結(jié)果**********************************
fprintf('%f\t%e\t%d\t\n',ebn0,ber1,nloop);
%plot(ber1);
%*******************************end of file********************************
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -