📄 convolutional_encode.m
字号:
%JC 9/20/07 Convolutional encoder-To run hit F5
% This m-file allows the user to input a source code to be encoded and
% input the values of the generator polynomials.
% It outputs the encoded data bits, where 1/n is the
% code rate.
% the rate is 1/n
% K is the constraint length
% m is the amount of memory
clear
g=[1 1 1;1 0 1];%generator polynomials
[n,K] = size(g);
m = K-1;%number of registers
state = zeros(1,m);%set registers to zero
inputx=[0 1 0 1 1 1 0 0 1 0 1 0 0 0 1];%encoder input source code
[trash,h]=size(inputx);
outputy=[];
for x=1:h%h=number of input bits
input=inputx(1,x);
for i=1:n
output(i) = g(i,1)*input;
for j = 2:K
z=g(i,j)*state(j-1);
output(i) = xor(output(i),z);
end;
end
state = [input, state(1:m-1)];
outputy=[outputy,output];%new element added to sequence
end
outputy%final encoder output in command window
%References and notes
%I reworked the code [encode_bit] in ref(1)and used ref(2) as a test for the encoder
%I'm not sure of it's accuracy when you use rate codes 1/3, 1/4 ,etc and
%larger K's and generators given in Proakis[Digital Communications-Fourth edition,pages
%492-494]
%http://www.ee.vt.edu/~yufei/turbo.html
%http://home.netcom.com/~chip.f/viterbi/algrthms.html#genalgorithm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -