📄 convolutional_trellis.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -