convolutional_encoder.m

来自「20072010.rar:tubor,LDPC,convolution的部分代码」· M 代码 · 共 28 行

M
28
字号
function [encoded_bits, final_state] = convolutional_encoder(input_bits, trellis, system_info, varargin)


% This function encodes the binary vector input_bits using the
% convolutional encoder whose trellis structure is trellis

% The initial_state specifies the starting state of the 
% encoder registers.

% It can also returns the final_state of the encoder's state.

current_state = 1;

nvarargin = nargin - 3;

switch(nvarargin)
    case {1}
        if isempty(varargin(1))
            current_state = varargin(1) + 1;
        end
end

for input = 1:system_info.uncoded_frame_length
    encoded_symbol = trellis.nextOutputs(current_state, input_bits(input) + 1);
    current_state = trellis.nextStates(current_state, input_bits(input) + 1) + 1;
    encoded_bits(((input - 1) * system_info.n + 1):(input * system_info.n)) = de2bi(encoded_symbol, system_info.n, 'left-msb');
end
final_state = current_state - 1;

⌨️ 快捷键说明

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