概述
本博文给出了4qam、16qam、64qam、256qam理论仿真曲线,画出了EbN0 vs BER的曲线图,可以作为大家学习的一个参考。
仿真结果:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Theoretical ber curves of different orders of QAM modulation
% Author: 苏大axing
% Version: 1.2
% Date: 2022/4/3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close all;
clear all;
clc
%% Parameters
EbN0_dB
= -5:20;
bits_per_symbol_for_4qam
= 2;
bits_per_symbol_for_16qam
= 4;
bits_per_symbol_for_64qam
= 6;
bits_per_symbol_for_256qam
= 8;
Nsym
= 2^18;
SNR_for_4qam
= EbN0_dB+10*log10(bits_per_symbol_for_4qam);
SNR_for_16qam
= EbN0_dB+10*log10(bits_per_symbol_for_16qam);
SNR_for_64qam
= EbN0_dB+10*log10(bits_per_symbol_for_64qam);
SNR_for_256qam
= EbN0_dB+10*log10(bits_per_symbol_for_256qam);
disp('
');disp('
');
disp('***********************************');
disp('generating binary bits');
disp('***********************************');
% Generating seeds
randn('state',12013)
rand('state',3693)
binary_bits_forqpsk
= randsrc(1,Nsym*bits_per_symbol_for_4qam,[0 1]);
binary_bits_for16qam
= randsrc(1,Nsym*bits_per_symbol_for_16qam,[0 1]);
binary_bits_for64qam
= randsrc(1,Nsym*bits_per_symbol_for_64qam,[0 1]);
binary_bits_for256qam
= randsrc(1,Nsym*bits_per_symbol_for_256qam,[0 1]);
% generating MQAM signals
disp('
');disp('
');
disp('***********************************');
disp('generating MQAM signal');
disp('***********************************');
%%%%%%%%%% 4QAM
paraller_for_4qam
= reshape(binary_bits_forqpsk,bits_per_symbol_for_4qam,Nsym);
k_4qam
= 2^bits_per_symbol_for_4qam;
[Output]
= BitsToInteger(paraller_for_4qam);
qam4_signal
= qammod(Output,k_4qam,'gray','UnitAveragePower', true);
% figure(1)
% subplot(2,2,1);
% plot(qam4_signal,'.');
% title('4QAM signal');
%%%%%%%%%% 16QAM
paraller_for_16qam
= reshape(binary_bits_for16qam,bits_per_symbol_for_16qam,Nsym);
k_16qam
= 2^bits_per_symbol_for_16qam;
[Output]
= BitsToInteger(paraller_for_16qam);
qam16_signal
= qammod(Output,k_16qam,'gray','UnitAveragePower', true);
% figure(1)
% subplot(2,2,2);
% plot(qam16_signal,'.');
% title('16QAM signal');
%%%%%%%%%% 64QAM
paraller_for_64qam
= reshape(binary_bits_for64qam,bits_per_symbol_for_64qam,Nsym);
k_64qam
= 2^bits_per_symbol_for_64qam;
[Output]
= BitsToInteger(paraller_for_64qam);
qam64_signal
= qammod(Output,k_64qam,'gray','UnitAveragePower', true);
% figure(1)
% subplot(2,2,3);
% plot(qam64_signal,'.');
% title('64QAM signal');
%%%%%%%%%% 256QAM
paraller_for_256qam
= reshape(binary_bits_for256qam,bits_per_symbol_for_256qam,Nsym);
k_256qam
= 2^bits_per_symbol_for_256qam;
[Output]
= BitsToInteger(paraller_for_256qam);
qam256_signal
= qammod(Output,k_256qam,'gray','UnitAveragePower', true);
% figure(1)
% subplot(2,2,4);
% plot(qam256_signal,'.');
% title('256QAM signal');
for i=1:length(EbN0_dB)
received_qam4
= awgn(qam4_signal,SNR_for_4qam(i),'measured');
received_qam16
= awgn(qam16_signal,SNR_for_16qam(i),'measured');
received_qam64
= awgn(qam64_signal,SNR_for_64qam(i),'measured');
received_qam256
= awgn(qam256_signal,SNR_for_256qam(i),'measured');
%% demodulation
%%%%%%%%%% 4QAM
demod_signal_for_4qam
= qamdemod(received_qam4,k_4qam,'gray','UnitAveragePower', true);
[Output]
= IntegerToBits(demod_signal_for_4qam,bits_per_symbol_for_4qam);
received_Bits_for_4qam
= reshape(Output,1,Nsym*bits_per_symbol_for_4qam);
ErrorNumber_for_4qam
= size(find(received_Bits_for_4qam-binary_bits_forqpsk),2);
BER_for_4qam(i)
= ErrorNumber_for_4qam/(Nsym*bits_per_symbol_for_4qam)
%%%%%%%%%% 16QAM
demod_signal_for_16qam
= qamdemod(received_qam16,k_16qam,'gray','UnitAveragePower', true);
[Output]
= IntegerToBits(demod_signal_for_16qam,bits_per_symbol_for_16qam);
received_Bits_for_16qam
= reshape(Output,1,Nsym*bits_per_symbol_for_16qam);
ErrorNumber_for_16qam
= size(find(received_Bits_for_16qam-binary_bits_for16qam),2);
BER_for_16qam(i)
= ErrorNumber_for_16qam/(Nsym*bits_per_symbol_for_16qam)
%%%%%%%%%% 64QAM
demod_signal_for_64qam
= qamdemod(received_qam64,k_64qam,'gray','UnitAveragePower', true);
[Output]
= IntegerToBits(demod_signal_for_64qam,bits_per_symbol_for_64qam);
received_Bits_for_64qam
= reshape(Output,1,Nsym*bits_per_symbol_for_64qam);
ErrorNumber_for_64qam
= size(find(received_Bits_for_64qam-binary_bits_for64qam),2);
BER_for_64qam(i)
= ErrorNumber_for_64qam/(Nsym*bits_per_symbol_for_64qam)
%%%%%%%%%% 256QAM
demod_signal_for_256qam
= qamdemod(received_qam256,k_256qam,'gray','UnitAveragePower', true);
[Output]
= IntegerToBits(demod_signal_for_256qam,bits_per_symbol_for_256qam);
received_Bits_for_256qam
= reshape(Output,1,Nsym*bits_per_symbol_for_256qam);
ErrorNumber_for_256qam
= size(find(received_Bits_for_256qam-binary_bits_for256qam),2);
BER_for_256qam(i)
= ErrorNumber_for_256qam/(Nsym*bits_per_symbol_for_256qam)
end
figure(2)
semilogy(EbN0_dB,BER_for_4qam,'g-<','MarkerFaceColor','g','LineWidth',1);hold on;
semilogy(EbN0_dB,BER_for_16qam,'m->','MarkerFaceColor','m','LineWidth',1);hold on;
semilogy(EbN0_dB,BER_for_64qam,'b-^','MarkerFaceColor','b','LineWidth',1);hold on;
semilogy(EbN0_dB,BER_for_256qam,'r-<','MarkerFaceColor','r','LineWidth',1);hold on;
axis([-5 20 1e-5 1]);
plot([-5 20],[3.8e-3,3.8e-3],'r','LineWidth',1);hold on;
grid on;
xlabel('E_{b}N_{0}(dB)');ylabel('BER');
legend('4qam','16qam','64qam ','256qam',...
'FEC(3.8x10^-^3)','Location','SouthWest');
function [Output] = BitsToInteger(input)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Convert Bits to Integer
% Author: Zhongxing Tian
% Version: 1.1
% Date: 2022/2/18
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[M,N] = size(input);
Value = zeros(1,N);
for i = 2:M
Value = Value+input(i,:).*2^(i-1); % 阶数从上到下(第一行最小
end
Value = Value+input(1,:);
Output = Value;
end
function [Output] = IntegerToBits(input,bits_per_symbol)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Convert Integer to Bits
% Author: Zhongxing Tian
% Version: 1.1
% Date: 2022/2/18
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[~,N] = size(input);
Value = zeros(bits_per_symbol,N);
for i = 1:N
k = 2^bits_per_symbol;
for j = 1:bits_per_symbol
if input(1,i)<k/2
Value(bits_per_symbol-j+1,i) = 0;% 阶数从上到下(第一行最小)
k = k-2^(bits_per_symbol-j);
else
Value(bits_per_symbol-j+1,i) = 1;
k = k+2^(bits_per_symbol-j);
end
end
end
Output = Value;
end
最后
以上就是淡定眼睛为你收集整理的4qam、16qam、64qam、256qam理论仿真曲线的全部内容,希望文章能够帮你解决4qam、16qam、64qam、256qam理论仿真曲线所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复