% Clear all the previously used variables and close all figures
clear all;
close all;
format long;
% Frame Length 'Should be multiple of four or else padding is needed'
bit_count = 4*1000;
% Range of SNR over which to simulate
Eb_No = -6: 1: 10;
% Convert Eb/No values to channel SNR
% Consult BERNARD SKLAR'S book 'Digital Communications, Principles
% and Applications'.
SNR = Eb_No + 10*log10(4);
% Start the main calculation loop
for aa = 1: 1: length(SNR)
% Initiate variables
T_Errors = 0;
T_bits = 0;
% Keep going until you get 100 errors
while T_Errors < 100
% Generate some random bits
uncoded_bits = round(rand(1,bit_count));
% Split the stream into 4 substreams
B = reshape(uncoded_bits,4,length(uncoded_bits)/4);
B1 = B(1,:);
B2 = B(2,:);
B3 = B(3,:);
B4 = B(4,:);
% 16-QAM modulator
% normalizing factor
a = sqrt(1/10);
% bit mapping
tx = a*(-2*(B3-0.5).*(3-2*B4)-j*2*(B1-0.5).*(3-2*B2));
% Noise variance
N0 = 1/10^(SNR(aa)/10);
% Send over Gaussian Link to the receiver
rx = tx + sqrt(N0/2)*(randn(1,length(tx))+i*randn(1,length(tx)));
%---------------------------------------------------------------
% 16-QAM demodulator at the Receiver
a = 1/sqrt(10);
B5 = imag(rx)<0;
B6 = (imag(rx)<2*a) & (imag(rx)>-2*a);
B7 = real(rx)<0;
B8 = (real(rx)<2*a) & (real(rx)>-2*a);
% Merge into single stream again
temp = [B5;B6;B7;B8];
B_hat = reshape(temp,1,4*length(temp));
% Calculate Bit Errors
diff = uncoded_bits - B_hat ;
T_Errors = T_Errors + sum(abs(diff));
T_bits = T_bits + length(uncoded_bits);
end
% Calculate Bit Error Rate
BER(aa) = T_Errors / T_bits;
disp(sprintf('bit error probability = %f',BER(aa)));
% Plot the received Symbol Constellation
figure;
grid on;
plot(rx,'x');
xlabel('Inphase Component');
ylabel('Quadrature Component');
Title('Constellation of Transmitted Symbols');
end
%------------------------------------------------------------
% Finally plot the BER Vs. SNR(dB) Curve on logarithmic scale
% BER through Simulation
figure(1);
semilogy(SNR,BER,'or');
hold on;
grid on
title('BER Vs SNR Curve for QAM-16 Modulation Scheme in AWGN');
xlabel('SNR (dB)'); ylabel('BER')
% Theoretical BER
figure(1);
theoryBer = (1/4)*3/2*erfc(sqrt(4*0.1*(10.^(Eb_No/10))));
semilogy(SNR,theoryBer);
legend('Simulated','Theoretical');
16_QAM.zip_QAM 误码率_QAM误码率
版权申诉
47 浏览量
2022-09-20
18:48:53
上传
评论
收藏 1KB ZIP 举报
林当时
- 粉丝: 100
- 资源: 1万+
最新资源
- uniapp中tab切换,底部内容跟着移动,相反,底部移动,tab也跟着切换-组件
- 基于JS+TS实现跨平台3D相机控制器-附项目源码-优质项目分享.zip
- 跨相机-基于Rust实现的跨平台相机捕获-附项目源码-优质项目分享.zip
- odise 14离线安装包 大众斯柯达奥迪 5054 6153
- 网页设计期末作业-纯html加css+少量js-盗墓笔记旅游导航网站.rar
- 算法笔记模拟退火.rar
- MATLAB大数据仿真案例-蚁群算法(ACO)用于求解旅行商(TSP)问题.rar
- 基于yolov5的吸烟行为检测源码+模型.zip
- MySQL基础知识-个人笔记.rar
- Project8.ipynb
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈