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

📄 encode_bit.m

📁 该程序是turbo码仿真程序,由12个m文件组成,分别是turbo编码(包括凿孔和非凿孔turbo码生成),译码网格和软判决迭代译码等模块,主程序可以直接运行,也可根据需要修改相应参数
💻 M
字号:
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
[n,k] = size(g);
m = k-1;

% determine the next output bit
for i=1:n
   output(i) = g(i,1)*input;    % the first bit a_k's contribution to output  --yzh
   for j = 2:k
      output(i) = xor(output(i),g(i,j)*state(j-1)); % a_(k-j)'s contribution to output  --yzh
      % why not use rem(g(i,j)*[input,state]'),j=1:k?  --yzh
   end;
end

state = [input, state(1:m-1)];  % shift one bit  --yzh


⌨️ 快捷键说明

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