1、卷积码编码 function [output]=cnv_encd(input) %output=cnv_encd(g,k0,input) 卷积码编码函数 %g 生成矩阵 %k0 输入码长 %input 输入信源序列 %output 输出卷积编码序列 g=[1 1 1;1 0 1];编码矩阵 k0=1; input=[1 1 0 1]; if rem(length(input),k0)>0 input=[input,zeros(size(1:k0-rem(length(input),k0)))]; end n=length(input)/k0; if rem(size(g,2),k0)>0 error('Error,g is not of the right size
') end li=size(g,2)/k0; n0=size(g,1); u=[zeros(size(1:(li-1)*k0)),input,zeros(size(1:(li-1)*k0))]; u1=u(li*k0:-1:1); for i=1:n+li-2 u1=[u1,u((i+li)*k0:-1:i*k0+1)]; end uu=reshape(u1,li*k0,n+li-1); output=reshape(rem(g*uu,2),1,n0*(n+li-1)); 2、Viterbi 译码程序 1) function y=bin2deci(x) l=length(x); y=(l-1:-1:0); y=2
^y; y=x*y'; 2) function y=deci2bin(x,l) y=zeros(1,l); i=1; while x>=0 & i