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

📄 convolution_dec.m

📁 通信中常用的卷积码信道译码源码程序
💻 M
字号:
function outputs = convolution_dec(Data_received,Trellis,Lut,alpha_channel);%------------------------------------------------------------------------------% Decode binary 1-D data vector with binary trellis (hard inputs).%% Format:% -------%% outputs = convolution_dec(Data_received,LData,Trellis,Lut,alpha_channel);% % Author: MVe% Date:   05.07.2002%------------------------------------------------------------------------------%% -- Initialisations -- %%% Length of the received symbol/data vectorLData = length(Data_received);% Extract most used variables from struct 'Trellis'm = Trellis.m;n = Trellis.n;k = Trellis.k;number_of_states = Trellis.StNr;init_path_bin = reshape([Trellis.Init_path_bin{:,1}],m*n,number_of_states).';% Number of output bits during init-state.init_outputs = m*n;% De-interleave dataData_received(alpha_channel) = Data_received;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- Calculate metrics for the time instances 1,2,...,m (init state) -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Keep track of distance metrics at different states.Metrics_dist = zeros(number_of_states,1);%% -- Calculate metrics during init-state. -- %%for i1 = 1:number_of_states  % Hard decisions (hamming metrics)  if ~Trellis.SoftDecF    Metrics_dist(i1,1) = length(find(init_path_bin(i1,:) ...                                     - Data_received(1:init_outputs)));  end % if Trellis.SoftDecFend % for i1 = number_of_states%% -- Some parameters for steady-state trellis -- %%% Length of the rest of the data in "symbols"LData_to_Decode = (LData-init_outputs)/n;% Aux variables.% Format: % Rows = states% Column = output with inputs 1,2,...,2^k%Metrics_dist_tmp = zeros(number_of_states,2^k);trellis_state_path_tmp = cell(number_of_states,2^k);% Precalculated variables (look in 'trellis_init.m' for more information)state_ptr = Trellis.Steady_state_ptr;state_prev_ptr = Trellis.Steady_state_prev_ptr;weigths_bin = Trellis.Steady_weigths_bin;trellis_state_path = Trellis.Init_state_path(:,1);%% ----------------------Trellis search-----------------------------% 1. State transitions caused by input sequences% 2. Outputs of these transitions.% 3. Distance-metrics between received sequence and transitions.% 4. Discard transitions to each state with higher distance-metrics.% 5. New transitions from surviving paths.%% -----------------------------------------------------------------%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- Steady-state trellis calculations begin (hard decisions) -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%for i1 = 1:LData_to_Decode      state_cnt = ones(number_of_states,1);    % Pointer for data vector  Data_ptr = n*m + [(i1-1)*n+1:i1*n];    % Calculate metrics-distances between paths and received sequence.  % Metrices are calculated so that first all metrics caused  % transition by sequence 00...00 are calculated, next all metrics  % caused transition by sequence 00...01, and so on.   %   for i2=1:number_of_states*2^k        % Check if this state has already some metrics calculated    if ~isempty(find(state_ptr(1:i2-1)==state_ptr(i2)))      state_cnt(state_ptr(i2)) = state_cnt(state_ptr(i2)) + 1;    end % if ~isempty(find(state_ptr(1:i2-1)==state_ptr(i2)))        %% -- METRICS begins -- %%        % -- Hard decisions -- %        % Calculate new metrics (hamming)    Metrics_dist_tmp(state_ptr(i2),state_cnt(state_ptr(i2))) = ...        Metrics_dist(state_prev_ptr(i2)) + ...        length(find((weigths_bin(i2,:) - Data_received(Data_ptr))));        %% -- METRICS ends -- %%        % Keep track of the paths that have lead to current states.    trellis_state_path_tmp{state_ptr(i2),state_cnt(state_ptr(i2))} = ...        [trellis_state_path{(state_prev_ptr(i2)),1},state_ptr(i2)];       end % for i2=1:number_of_states*2^k         % Find the survivors  [Metrics_dist, survivor_ptr] = min(Metrics_dist_tmp,[],2);  % Surviving paths  for i2 = 1:number_of_states    trellis_state_path(i2,1) = trellis_state_path_tmp(i2,survivor_ptr(i2));  end % for i2 = 1:number_of_states  end % for i1 = 1:LData_to_Decode  % Surviving state path[dummy, decode_ptr] = min(Metrics_dist,[],1);final_state_path = trellis_state_path{decode_ptr,:};% Convert state path to info bit sequenceout_tmp = cell(1,length(final_state_path)-1);for i1 = 1:length(out_tmp)  out_tmp(i1) = ...      Lut.InfBits(final_state_path(i1),final_state_path(i1+1));end % for i1 = 1:2:length(Data_received)outputs = [out_tmp{:}];

⌨️ 快捷键说明

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