部分源码:
% 首先加载G , H
clear all
load G.mat;
load H.mat;
max_iter=50;
L_frame=size(G,1);
n_frame=100;
start=0;
step=2;
finish=12;
r=size(G,1)/size(G,2);
M=6;
Es=42; % 一个64QAM符号能量 也是信号功率
Eb=Es/M;
plot_pe=[];
Q=1;
% err_list_index=1; % used by test
axis_EbN0=start:step:finish;
%******************************************************
for EbN0=start:step:finish;
Liner_EbN0=10^(EbN0/10);
pe_number=0;
variance=0.5*(Eb/Liner_EbN0)/r; % 噪声方差, 来源于a^2/(2*delta^2)=Liner_EbN0,a^2信息幅值的平方即比特能量, 2*delta^2=N0. N0/r得到编码后的噪声功率谱密度
for number_frame=1:1:n_frame % variance是单独加在同相(正交相)的噪声功率普密度
[EbN0,number_frame]
x_msg = (sign(randn(1,size(G,1)))+1)/2; % random bits
x_code_msg= mod(x_msg*G,2); % coding
in=x_code_msg;
x_tx_msg= QAM64m(in); % 16QAM modulation
real_tx=real(x_tx_msg); imag_tx=imag(x_tx_msg);
waveform= x_tx_msg+sqrt(variance)*( randn(size(real_tx)) + randn(size(imag_tx))*i ) ; % AWGN transmission
[f0,f1]=QAM64d(waveform,2*variance);
LLR=log(f0./(f1+eps));
[z_hat, success, k] = log_ldpc_decode(H,LLR,max_iter);; % likelihoods
x_dec_msg = z_hat(1:size(G,1)); % 码率1/2 时使用
% if success==0 % used by test
% err_list(err_list_index,1)=number_frame; % 第一列代表含有错误的frame的号数
% err_list(err_list_index,2)=sum(x_msg~=x_dec_msg); % 第二列代表错误的个数
% err_list_index=err_list_index+1;
% end
pe_number=pe_number+sum(x_msg~=x_dec_msg);
current_time=fix(clock);
fprintf('i am working %g,total(%g) %g年 %g月 %g日 %g时 %g分 %g秒\n\n',Q,(((finish-start)/step)+1)*n_frame,current_time(1),current_time(2),current_time(3),current_time(4),current_time(5),current_time(6))
Q=Q+1;
fprintf('\n\n')
end
pe=pe_number/(L_frame*n_frame);
plot_pe=[plot_pe,pe];
end
semilogy(axis_EbN0,plot_pe,'b*-')
xlabel('Eb/N0 信号功率/噪声功率(db)')
ylabel('BER')
title('误码率')
grid on
误码率曲线如下:
D170
标签:64QAM,tx,frame,LDPC,EbN0,current,MATLAB,pe,msg From: https://www.cnblogs.com/matlabfpga/p/16893349.html