pr9_27.m

来自「Spread Spectrum and CDMA Principles and 」· M 代码 · 共 24 行

M
24
字号
%Problem 9.27;
%convolutional encoding/decoding using Communication Toolbox;

G=[47,53,75]; %1 by n matrix of generator polynomials in octal form;
Gb=de2bi(oct2dec(G'),'left-msb'); %conversion octal-number representation of generation polynomial to binary vectors;
[i,j]=find(Gb); nzcl=min(j); Gb=Gb(:,nzcl:end); %removal of left zero-padding;
nu=size(Gb,2); %constraint length;
n=size(G,2); %frame length;
L=10*nu*n; %length of the block to decode;
Tr=poly2trellis(nu,G); %creating trellis;
we=18; %weight of error vector;
Sm=0; %initialize bit error counting;
N=1000; %number of trials;
trback=5*nu; %depth of tracing back before releasing bit;
for k=1:N
    e=randerr(1,L,we); %error vector;
    ud=vitdec(e,Tr,trback,'term','hard'); %decoding;
    er=sum(ud); %number of errors;
    Sm=Sm+er; %accumulated numbrer of bit errors;
end;
BER=Sm/(N*10*nu)+eps; %BER, eps is added to make a convenient output format;
fprintf('\n'); disp('generator polynomials'); disp(num2str(G')); fprintf('\n');
fprintf('\n'); disp('   cnstlg    trback    erweight    BER'); 
fprintf('\n'); disp([nu,trback,we,BER]);fprintf('\n');

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?