outer_decode_u.asv
来自「短波信道抗多音干扰的性能分析及其仿真」· ASV 代码 · 共 124 行
ASV
124 行
%function outer_out_u=outer_decode_u(outer_input,trellis,formerstate)
% this function does the MAP decode process of the
% outer convolutional code to recover the information
source=[1,0 1 0 0 0 1 0 0 0];
outer_input=[-80 -30.985 80 -0.28763 -80 71.033 -12.165 13.807 -80 80;
-80 -18.759 -25.702 5.7169 -80 10.152 -9.7001 -4.3942 -80 -34.39;
-80 17.744 -27.097 80 -80 -8.6871 -9.3323 80 -80 25.345];
outer_input=outer_input/10;
trellis=poly2trellis(3,[7,5]);
formerstate(:,:,1)=[0,1;2,3;4,4;4,4];
formerstate(:,:,2)=[4,4;4,4;0,1;2,3];
outer_input=outer_input/2;
number_of_states=trellis.numStates;
nextstate=trellis.nextStates;
fanout=trellis.numInputSymbols;
output=trellis.outputs;
number_of_out=trellis.numOutputSymbols;
depth_of_trellis=length(outer_input);
alpha=zeros(number_of_states,depth_of_trellis);
alpha(:,1)=[0;-1e10*ones(number_of_states-1,1)];
alpha1=zeros(1,fanout);
gamma=zeros(2*fanout,depth_of_trellis);
max=-1e10*ones(1,depth_of_trellis-1);
beta=zeros(number_of_states,depth_of_trellis);
beta(:,depth_of_trellis)=[0;-1e10*ones(number_of_states-1,1)];
beta1=zeros(1,fanout);
%trace forward to compute alpha
for i=1:depth_of_trellis-1
for j=1:number_of_states
for k=1:fanout
if(formerstate(j,1,k)~=number_of_states)
for h=1:fanout
t=output(formerstate(j,h,k)+1,k)+1;
if(t~=number_of_out)
gamma(h,i)=outer_input(t,i);
else
gamma(h,i)=0;
end
alpha1(h)=alpha(formerstate(j,h,k)+1,i)+gamma(h,i);
if(alpha1(h)<=-80)
alpha1(h)=0;
else
alpha1(h)=exp(alpha1(h));
end
end
if(sum(alpha1)>1e-30)
alpha(j,i+1)=log(sum(alpha1));
else
alpha(j,i+1)=-1e10;
end
if(max(i)<alpha(j,i+1))
max(i)=alpha(j,i+1);
end
end
end
end
alpha(:,i+1)=alpha(:,i+1)-max(i);
end
for j=1:number_of_states
for k=1:fanout
if(formerstate(j,1,k)~=number_of_states)
for h=1:fanout
t=output(formerstate(j,h,k)+1,k)+1;
if(t~=number_of_out)
gamma(h,depth_of_trellis)=outer_input(t,depth_of_trellis);
else
gamma(h,depth_of_trellis)=0;
end
end
end
end
end
for i=depth_of_trellis:-1:2
temp=zeros(1,fanout);
for j=1:number_of_states
for k=1:fanout
t=output(j,k)+1;
if(t~=number_of_out)
gamma(k+fanout,i)=outer_input(t,i);
else
gamma(k+fanout,i)=0;
end
beta1(k)=beta(nextstate(j,k)+1,i)+gamma(k+fanout,i);
if(beta1(k)<=-80)
beta1(k)=0;
else
beta1(k)=exp(beta1(k));
end
temp(k)=temp(k)+exp(alpha(j,i)+gamma(k+fanout,i)+beta(nextstate(j,k)+1,i));
end
if(sum(beta1)>1e-30)
beta(j,i-1)=log(sum(beta1))-max(i-1);
else
beta(j,i-1)=-1e10;
end
end
[C,I]=max(temp);
outer_out_u(i)=I-1;
end
temp=zeros(1,fanout);
for j=1:number_of_states
for k=1:fanout
t=output(j,k)+1;
if(t~=number_of_out)
gamma(k+fanout,1)=outer_input(t,1);
else
gamma(k+fanout,1)=0;
end
temp(k)=temp(k)+exp(alpha(j,1)+gamma(k+fanout,1)+beta(nextstate(j,k)+1,1));
end
end
[C,I]=max(temp);
outer_out_u(1)=I-1;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?