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

📄 trellis_init.m

📁 通信中常用的卷积码信道译码源码程序
💻 M
字号:
function Trellis = trellis_init(Trellis, Lut);%------------------------------------------------------------------------------% Calculate the transitions during time instants 1,2,...,m in trellis.% % Format:% -------% % Trellis = trellis_init(Trellis, Lut)% % Author: MVe% Date:   03.07.2002%------------------------------------------------------------------------------% Format of 'init_state_ptr':%  Row = previous state%  Column = current state with inputs 1,2,...,2^Trellis.k%init_state_ptr = 1;% All possible input sequencesinit_state_input = [1:2^Trellis.k].';% Binary presentation of the paths% Format: %  row = state%  Column 1 = path at previous time instant%  Column 2 = path now% Trellis.Init_path_bin = cell(Trellis.StNr,2);% "Symbol" presentation of the paths% Format: %  row = state%  Column 1 = path at previous time instant%  Column 2 = path now% Trellis.Init_path = cell(Trellis.StNr,2);% State presentation of the paths% Format: %  row = state%  Column 1 = state at previous time instant%  Column 2 = state now%Trellis.Init_state_path = cell(Trellis.StNr,2);[Trellis.Init_state_path{:}] = deal(1);% Format of 'trellis_state_new':%  Row = previous state%  Column = new state with inputs 1,2,...,2^Trellis.k%trellis_state_new = zeros(Trellis.StNr,2^Trellis.k);% Aux pointer for distance-metrics calculation.state_prev_ptr = 0;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- "Fill" the states occured during time instances 1,2,...,m -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%for i1 = 1:Trellis.m    % States of the trellis after current transitions.  trellis_state_new(init_state_ptr,:) = ...      Trellis.NextState(init_state_ptr, init_state_input);  % CHECK IS THIS CORRECT!!!  % Aux pointer of previous states. For calculating the distance-metrics.  state_prev_ptr = kron(ones(1,2^Trellis.k),init_state_ptr);  % Points to the values to be read from look-up tables.   %  Column 1 corresponds to transitions caused by 00...00   %  Column 2 corresponds to transitions caused by 00...01   %  Column 3 corresponds to transitions caused by 00...11   %    etc..  %  index_ptr = reshape(find(trellis_state_new), ...		      length(find(trellis_state_new))/2^Trellis.k, ...		      2^Trellis.k);  weigths_ptr = Trellis.Output(index_ptr(:,:));  % New state pointer  init_state_ptr = trellis_state_new(index_ptr);    % Path outputs in binary and "symbol" format.  weigths_bin = Lut.Outputs_bin(weigths_ptr,:);  weigths = Lut.Outputs(weigths_ptr,1);    %% -- METRICS dependant begins -- %%  % Calculate all paths during this time instant.  for i2=1:size(weigths_bin,1)    Trellis.Init_path_bin{init_state_ptr(i2),2} = ...        [Trellis.Init_path_bin{(state_prev_ptr(i2)),1}, weigths_bin(i2,:)];    Trellis.Init_path{init_state_ptr(i2),2} = ...        [Trellis.Init_path{(state_prev_ptr(i2)),1}, weigths(i2)];    Trellis.Init_state_path{init_state_ptr(i2),2} = ...        [Trellis.Init_state_path{(state_prev_ptr(i2)),1}, ...         init_state_ptr(i2)];  end % for i2=1:size(index_ptr,1)  %% -- METRICS dependant ends -- %%  % Rotate buffers  Trellis.Init_state_path = [Trellis.Init_state_path(:,2), ...		    cell(Trellis.StNr,1)];  Trellis.Init_path_bin = [Trellis.Init_path_bin(:,2), ...		    cell(Trellis.StNr,1)];  Trellis.Init_path = [Trellis.Init_path(:,2), ...		    cell(Trellis.StNr,1)];end % for i1 = 1:Trellis.m%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- Create necessary pointers and variables for steady-state trellis  -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Some pre-calculated variablesstate_ptr = init_state_ptr;state_input = init_state_input;% Format of 'state_new':% Row = previous state% Column = new state with inputs 1,2,...,2^Trellis.k%state_new = zeros(Trellis.StNr,2^Trellis.k);% States of the trellis after transitions.state_new(state_ptr,:) = Trellis.NextState(state_ptr, state_input);% Points to the values to be read from look-up tables.% Format: % Rows = states%  Column 1 corresponds to transitions caused by 00...00 %  Column 2 corresponds to transitions caused by 00...01 %    etc.%index_ptr = reshape(find(state_new), ...		    length(find(state_new))/2^Trellis.k, 2^Trellis.k);% Pointer for path outputsweigths_ptr = Trellis.Output(index_ptr(:,:));% Path outputs in binary format.Trellis.Steady_weigths_bin = Lut.Outputs_bin(weigths_ptr,:);Trellis.Steady_weigths = Lut.Outputs(weigths_ptr,1);% New state pointerTrellis.Steady_state_ptr = state_new(index_ptr);% Pointer to previous states. For calculating the metrics.Trellis.Steady_state_prev_ptr = kron(ones(1,2^Trellis.k),(1:Trellis.StNr));

⌨️ 快捷键说明

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