encode_bit.m
来自「3GPP标准Turbo码编码译码仿真Matlab6.5及VC6.0源代码」· M 代码 · 共 37 行
M
37 行
function [output, state] = encode_bit(g, input, state)% Copyright 1996 Matthew C. Valenti% MPRG lab, Virginia Tech% for academic use only% This function takes as an input a single bit to be encoded,% as well as the coeficients of the generator polynomials and% the current state vector.% It returns as output n 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%*****************************************************************% 根据生产矩阵多项式g和输入比特input 寄存器的当前状态% 进行编码 % 输出为 (编码比特 编码后寄存器的状态)% 编码比特(1 2 3 。。。。)% 对应着生产矩阵的每一列。%*****************************************************************[n,k] = size(g);m = k-1;% determine the next output bitfor i=1:n output(i) = g(i,1)*input; % 第一个寄存器前的一个比特编码值 for j = 2:k output(i) = xor(output(i),g(i,j)*state(j-1)); % xor 二进制 加法 end;endstate = [input, state(1:m-1)];% 寄存器状态转移
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?