?? vitdemod.m
字號(hào):
function decoder_output=vitdemod(demod_input,nextstate,fanout,number_of_states,input,output,sgma21,sgma22)
% this function simulates the viterbi demodulation
% of the DFH system
depth_of_trellis=size(demod_input,2);
state_metric=zeros(number_of_states,2);
survivor_state=zeros(number_of_states,depth_of_trellis+1);
L=floor(log(number_of_states)/log(fanout));
BPH=log2(fanout);
% start viterbi demodulation
for i=1:depth_of_trellis
flag=zeros(1,number_of_states);
if i<=L+1
step=2^((L+1-i)*BPH);
else
step=1;
end
for j=0:step:number_of_states-1
for m=0:fanout-1
%branch_metric=demod_input(output(j+1,m+1)+1,i);
sel=demod_input(output(j+1,m+1)+1,i);
neg=sum(demod_input(:,i))-sel;
branch_metric=-(sel/sgma21+neg/sgma22);
if((state_metric(nextstate(j+1,m+1)+1,2)<state_metric(j+1,1)...
+branch_metric)|flag(nextstate(j+1,m+1)+1)==0)
state_metric(nextstate(j+1,m+1)+1,2)=state_metric(j+1,1)+branch_metric;
survivor_state(nextstate(j+1,m+1)+1,i+1)=j;
flag(nextstate(j+1,m+1)+1)=1;
end
end
end
state_metric=state_metric(:,2:-1:1);
end
state_sequence=zeros(1,depth_of_trellis+1);
[C,I]=max(state_metric(:,1));
state_sequence(depth_of_trellis+1)=I-1;
decoder_output=zeros(1,depth_of_trellis);
for i=1:depth_of_trellis
state_sequence(1,depth_of_trellis-i+1)=survivor_state((state_sequence(1,depth_of_trellis-i+2)...
+1),depth_of_trellis-i+2);
decoder_output(1,depth_of_trellis-i+1)=input(state_sequence(1,depth_of_trellis-i+1)+1,...
state_sequence(1,depth_of_trellis-i+2)+1);
end
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -