📄 cm_sm32_golay.m
字号:
function [pb1]=cm_sm32_golay(EbNo)
% [pb1]=cm_sm32_golay(EbNo)
% CM_SM32_golay finds the probability of bit error for
% the given value of EbNo(dB).
%
%
%
N=5000;
E=1; % energy per symbol
snr=10^(EbNo/20); % EcNo
sgma=sqrt(E/(2*snr)); % noise variance
%************* generation of the data source
dsource=zeros(N,24);
dsource1=zeros(N,24);
numofbiterror=0;
for i=1:N,
%************* Generator 12 bits information bits used to generate golay code
C=rand(1,12)>0.5;
[codeword]=golay24_encode(C);
%********** Generate 24 bits golay code
dsource(i,:)=codeword;
dsource1(i,:)=codeword;
temp=dsource(i,:);
for j=1:24 %0->1,1->-1
if (temp(j)==0)
dsource(i,j)=1;
else
dsource(i,j)=-1;
end
end
end
%********** detection and the probability of error calculation
for i=1:N,
%********** the received signal at the detection, for the ith symbol,is:
s=dsource(i,:);
n=sgma*randn(1,24); % 1*24 normal distributed r.v with 0, variance sgma
ss=s+n;
for j=1:24
if (ss(j)>=0)
s(j)=0;
elseif (ss(j)<0)
s(j)=1;
end
end
%disp(s);
%********* Decode the 24 bits codeword after the demoduationg of bpsk
[final_data]=golay24_decode(s);
%decis(i)=final_data;
decis=xor(dsource1(i,:),final_data);
%disp(decis);
%******** Calculate the number of error bits
if (sum(decis))
numofbiterror=numofbiterror+sum(decis);
end
end
pb1=numofbiterror/(24*N); %since 24*N bits are transmitted
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -