📄 estimatebitwef.m
字号:
function [Bd, dfree]=EstimateBitWEF(Gpoly)
% [Bd, dfree]=EstimateBitWEF(Gpoly)
% Bd: info. bit WEF weight enumerating function of the code
% dfree: free distance of the code
%
% Estimates via simulation the information-bits WEF (weight enumerating function) of a
% convolutional code specified by Gpoly (genrator matrix in octal format)
%
% For more info on the QA, see for example:
% "Error Control Coding", Lin & Costello, 2nd edition p 530-535
% "Simulation of Communication Systems", Jeruchim et al, 1992, p 619
%
% See also ComputeBerSoftDecicionUnquantized
%
% (c) Dr B. Gremont, 2007
[K, M, nu, n, k, coderate, StateTable]=getcodeparameters(Gpoly);
NoBits=50; % How many bit are to be sent
% Note: long sequences take a lot of memory
% resulting in long decoding times
Mary=2; % M-arity of the MPSK modulation
disp('This is a simulation of :')
disp(['Rate ' num2str(k) '/' num2str(n) ' encoded ' num2str(Mary) 'PSK']);
NoOfWords=2000; % No if non-zero input words to be used to compute
% the weight enumerating function (WEF) of the code
% increase this number to get a more precise WEF.
%===============================================================
% Compute experimental bit WEF (weight enumeraiting function)
% see Shu Lin & Costello p 498
% and Jeruchim p 618
%===============================================================
Bd=zeros(1,NoBits.*n./k); % this is the histogram in which the estimated weights
% is to be stored in
for i=1:NoOfWords,
clc
disp(['Sim: ' num2str(100.*i./NoOfWords) ' %'])
m=deci2bin(i,NoBits);
%===============================================================
% Prepare data by adding leading/trailing zeros to start/end in the zero
% state
%===============================================================
% first add k*nu leading zeros to start from 0 state
m2=[zeros(1,k.*nu) m zeros(1,k.*nu)];
NoOfLeadingAddedZeros=k.*nu;
% add extra zeros to make m a multiple of k
if rem(length(m2),k) > 0 % length(m) must be a multiple of k
% No of input bits to encoder
ExtraZeros=zeros(size(1:k-rem(length(m),k)));
NoOfExtraZeros=length(ExtraZeros);
m2=[m2 ExtraZeros]; % add the zeros
NoOFTrailingAddedZeros=k.*nu+NoOfExtraZeros;
else
NoOFTrailingAddedZeros=k.*nu;
end
%===============================================================
% Encode Data Using Convolutional encoder
%===============================================================
[c,c_bin,PathThroughTrellis]=CVencode(m2,k,n,StateTable);
%===============================================================
% Estimate the information bit WEF
%===============================================================
d=length(find(c_bin==1)); % Hamming weight of codeword
w=length(find(m2==1)); % Hamming weight of input sequence
if w>0 & d<=length(Bd),
Bd(d)=Bd(d)+w; % increment WEF
end
end
Bd=Bd./k;
% Note: estimated free distance of the code is the position of the first non-zero
% term in the information-bit WEF
I=find(Bd>0);
dfree=I(1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -