📄 mtx_encode_bit.m
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Property of Freescale
% Freescale Confidential Proprietary
% Freescale Copyright (C) 2005 All rights reserved
% ----------------------------------------------------------------------------
% $RCSfile: mTx_encode_bit.m.rca $
% $Revision: 1.1 $
% $Date: Mon Jan 22 10:28:18 2007 $
% Target: Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% [output, state] = mTx_encode_bit(g, input, inputB, state) encodes
% one pair of data and outputs two parity bits Y, W
%
% Outputs:
% output => Encoded data bits. First two bits are set to 0 for the
% systematic bits
% state => New state vector.
%
% Inputs:
% g => Generator polynomial.
% input => Encoded inputA.
% inputB => B value in each pair.
% state => Current state vector.
function [output, state] = mTx_encode_bit(g, input, inputB, state)
% k is the constraint length
% m is the amount of memory
[n,k] = size(g);
m = k-1;
% % Set the first two bits to zero.
parity_bit = rem(g*[input,state(1:m)]',2)';
output = [0,0,parity_bit(2:n)];
% New state vector
state = xor(state,inputB);
state = [input, state(1:m-1)];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -