✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
基于Matlab模拟 AWGN 中16-QAM 的 OFDM 并计算 BER附完整代码
⛄完整代码
clear all
close all
clc
nbits = 208000;
modlevel = 2 ;
nbitpersym = 52; % number of bits per qam OFDM symbol (same as the number of subcarriers for 16-qam)
nsym = 10^4; % number of symbols
len_fft = 64; % fft size
sub_car = 52; % number of data subcarriers
EbNo = 0:2:15;
EsNo= EbNo+10*log10(52/64)+ 10*log10(64/80) +10*log10(4);
snr=EsNo - 10*log10((64/80));
M = modem.qammod('M',16); % modulation object
% Generating data
t_data=randint(nbitpersym*nsym*4,1,2);
qamdata=bi2de(reshape(t_data,4,520000).','left-msb');
maping = bin2gray(qamdata,'qam',16);
% modulating data
mod_data =1/sqrt(10)* modulate(M,maping);
% serial to parallel conversion
par_data = reshape(mod_data,nbitpersym,nsym).';
% pilot insertion
pilot_ins_data=[zeros(nsym,6) par_data(:,[1:nbitpersym/2]) zeros(nsym,1) par_data(:,[nbitpersym/2+1:nbitpersym]) zeros(nsym,5)] ;
% fourier transform time doamain data
IFFT_data =ifft(fftshift(pilot_ins_data.')).';
a=max(max(abs(IFFT_data)));
IFFT_data=IFFT_data./a; % normalization
% addition cyclic prefix
cylic_add_data = [IFFT_data(:,[49:64]) IFFT_data].';
% parallel to serial coversion
ser_data = reshape(cylic_add_data,80*nsym,1);
% passing thru channel
no_of_error=[];
ratio=[];
for ii=1:length(snr)
chan_awgn = awgn(ser_data,snr(ii),'measured'); % awgn addition
ser_to_para = reshape(chan_awgn,80,nsym).'; % serial to parallel coversion
cyclic_pre_rem = ser_to_para(:,[17:80]); %cyclic prefix removal
FFT_recdata =a*fftshift(fft(cyclic_pre_rem.')).'; % freq domain transform
rem_pilot = FFT_recdata (:,[6+[1:nbitpersym/2] 7+[nbitpersym/2+1:nbitpersym] ]); %pilot removal
ser_data_1 =sqrt(10)* reshape(rem_pilot.',nbitpersym*nsym,1); % serial coversion
z=modem.qamdemod('M',16);
demod_Data = demodulate(z,ser_data_1); %demodulatin the data
demaping = gray2bin(demod_Data,'qam',16);
data1 = de2bi(demaping,'left-msb');
data2 = reshape(data1.',nbitpersym*nsym*4,1);
[no_of_error(ii),ratio(ii)]=biterr(t_data , data2) ; % error rate calculation
end
% plotting the result
semilogy(EbNo,ratio,'--*r','linewidth',2);
hold on;
theoryBer = (1/4)*3/2*erfc(sqrt(4*0.1*(10.^(EbNo/10))));
semilogy(EbNo,theoryBer ,'--b','linewidth',2);
axis([0 15 10^-5 1])
legend('simulated','theoritical')
grid on
xlabel('EbNo');
ylabel('BER')
title('Bit error probability curve for qam using OFDM');
⛄ 运行结果
⛄ 参考文献
[1] Tahir M . BER of OFDM using 16-QAM in AWGN[J].
❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料