⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 convolenc.m

📁 CRC码生成器和卷积码的仿真程序。其中CRC码可以自定义生成多相式或字符串;卷积码可以自定义约束长度和码长。
💻 M
字号:
function[output,GP]=convolenc(input,k);

%Abhijith. S, PAACET, India.

%Convolutional Encoder with m=k-1 shift register stages
%Code rate 1/2 bits/symbol
%m is the number of shift registers
%k is the constraint length

%Takes input bit sequence of any length,Constraint length 
%can be any value, k>3          
%Returns the encoded sequence & generator polynomial
%Pattern of generator polynomial is takes as
%GP=[1 1 1 1 1. . .;1 0 1 0 1 . . .]
%It is obtained from the constraint length

%obtain the state changed matrix of the input

L=size(input);m=k-1;
len=L(2);
for h=1:len
    temp(h+m)=input(h);
end
g=size(temp);
gen=g(2);
temp(len+2*m)=0;
for d=1:gen
    e=d-1;
      for i=1:k
      result(i,d)=temp(i+e);
      end
end

%Perform modulo 2 additions

s=2;
for r=1:gen
tmr(r)=xor(result(k,r),result(k-1,r));
end
while k-s>=1
    for r=1:gen
      temr(r)=xor(tmr(r),result(k-s,r));
      tmr(r)=temr(r);
    end
s=s+1;
end

re=1;
for ver=1:2:k
     pathres(re,:)=result(ver,:);
     re=re+1;
end

lp=size(pathres);lq=lp(1);

u=2;
for t=1:gen
tmoub(t)=xor(pathres(lq,t),pathres(lq-1,t));
end
if(lq==2)
    outb=tmoub;
end

while lq-u>=1
    for t=1:gen
      outb(t)=xor(tmoub(t),pathres(lq-u,t));
      tmoub(t)=outb(t);
    end
u=u+1;
end

%Multiplex path1 and path2 outputs by merging 

c=2*gen;
y=0;
for x=1:2:c
    output(x)=temr(x-y);
    y=y+1;
end
a=1;
for z=2:2:c
    output(z)=outb(z-a);
    a=a+1;
end

%obtain generator polynomial using k

for w=1:k
    GP(1,w)=1;
    GP(2,w)=0;
end
for hy=1:2:k
    GP(2,hy)=1;
end

⌨️ 快捷键说明

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