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

📄 codeword.m

📁 卷积码的编码及解码代码
💻 M
字号:
function [c0, c1] = codeWord(nrSt, G)
% Create codewords when the input is '0' and '1'
% nrSt, number of state
% G, generator matrix
%
% c0, codeword when input is '0'
% c1, codeword when input is '1'

% Find the code rate denominator R and constraint lengths K
[R, K] = size(G);

% Code words matrices
c0 = [];  c1 = [];

for state = 0:nrSt - 1

   % Code words for '0'
   tmpBit = bitand( G, repmat( dec2bin( state, K) - 48, R, 1));
   c0 = [c0; mod( sum( tmpBit, 2), 2)'];
   
   % Code words for '1'
   tmpBit = bitand( G, repmat( dec2bin( state + nrSt, K) - 48, R, 1));
   c1 = [c1; mod( sum( tmpBit, 2), 2)'];   
end

% The output size must be R times nrSt (-1/1)
c0 = 2*c0' - 1;
c1 = 2*c1' - 1;

⌨️ 快捷键说明

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