convolutional_trellis.m
来自「20072010.rar:tubor,LDPC,convolution的部分代码」· M 代码 · 共 37 行
M
37 行
function trellis = convolutional_trellis(generator_matrix, system_info)
%
% This function accepts a polynomial description of the
% convolutional encoder and returns the corresponding trellis
% structure description.
% Assumptions : a) Only 1 input bit, i.e. k = 1
% b) Only binary states
memory_length = system_info.constraint_length - 1;
trellis.numStates = 2 ^ memory_length;
trellis.numInputSymbols = 2;
trellis.numOutputSymbols = 2 ^ system_info.n;
for state = 1:trellis.numStates
state_vector = de2bi(state - 1, memory_length, 'left-msb');
for input_bit = 0:1
trellis.nextStates(state,input_bit + 1) = bi2de([input_bit state_vector(1:(memory_length - 1))], 'left-msb');
for output = 1:system_info.n
binary_outputs(output) = rem(generator_matrix(output,:) * [input_bit state_vector]', 2);
end
trellis.nextOutputs(state,input_bit + 1) = bi2de(binary_outputs,'left-msb');
end
end
counter = zeros(trellis.numStates);
for state = 1:trellis.numStates
for bit = 1:2
next_state = trellis.nextStates(state, bit) + 1;
counter(next_state) = counter(next_state) + 1;
trellis.lastStates(next_state, counter(next_state)) = state - 1;
trellis.lastOutputs(next_state, counter(next_state)) = trellis.nextOutputs(state, bit);
trellis.lastBits(next_state, counter(next_state)) = bit - 1;
end
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?