📄 awgntest.m
字号:
% This is a program to test OFDM on AWGN
clc
N=256;
NL=10;
KL=4*N*NL;
% ep=0.2;
% epgj=0.198;
SNR_dB = 0:2:20;
% theo_pb=BPSK_err(SNR_dB);
for l=1:length(SNR_dB),
num_of_err=0;
num_of_err0=0;
num_of_err2=0;
snr=10^(SNR_dB(l)/10);
sgma=sqrt(4/(N*snr)); % noise standard deviation
for i=1:NL
input=rand(1,4*N); %输入的二进制数据序列
for i=1:4*N
if input(i)>0.5
input(i)=1;
else
input(i)=0;
end
end
% end
% end
for n=1:N
for ic=1:4
qam_input(ic)=input((n-1)*4+ic); %qam的输入
end
qam_out(n)=qam16(qam_input); %qam的输出
end
inputqam=qam_out;
for n=1:N
noise(n)=normrnd(0,sgma)+normrnd(0,sgma)*sqrt(-1); %输入的随机噪声
end
transa=ifft(inputqam,N);
receb=transa+noise;
zk=fft(receb,N);
ofdmout2=zk
ij=1;
for i=0:N-1
output2=de_qam16(ofdmout2(i+1));
outqam2(ij:ij+3)=output2;
ij=ij+4;
end
inx=input;
outy2=outqam2;
for iy=1:4*N
if inx(iy) ~= outy2(iy)
num_of_err2=num_of_err2+1;
end
end
end
ber2(l)=num_of_err2/KL;
end
% figure(1)
semilogy(SNR_dB,ber2,'k-o')
axis([0,20,1e-6,1])
grid on
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -