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

📄 trellis.m

📁 是一个对mimo连续相位调制系统的均衡程序
💻 M
字号:
function [next_out0, next_state0, last_out0, last_state0, last_out1, last_state1] = trellis(g)


% set up the trellis given code generator g
% g given in binary matrix form. e.g. g = [ 1 1 1; 1 0 1 ];

% next_out(i,1:2): trellis next_out (systematic bit; parity bit) when input = 0, state = i; next_out(i,j) = -1 or 1
% next_out(i,3:4): trellis next_out  (systematic bit; parity bit) when input = 1, state = i;
% next_state(i,1): next state when input = 0, state = i;next_state(i,i) = 1,...2^m
% next_state(i,2): next state when input = 1, state = i;
% last_out(i,1:2): trellis last_out (systematic bit; parity bit) when input = 0, state = i; last_out(i,j) = -1 or 1
% last_out(i,3:4): trellis last_out  (systematic bit; parity bit) when input = 1, state = i;
% last_state(i,1): previous state that comes to state i when info. bit = 0;
% last_state(i,2): previous state that comes to state i when info. bit = 1;

[n,K] = size(g);
m = K - 1;
max_state = 2^m;

% set up next_out and next_state matrices for systematic code
for state=1:max_state
   state_vector = bin_state( state-1, m );
  
   % when receive a 0
   d_k = 0;
   a_k = rem( g(1,:)*[0 state_vector]', 2 );
   [out_0, state_0] = encode_bit(g, a_k, state_vector);
   out_0(1) = 0;
 
   % when receive a 1
   d_k = 1;
   a_k = rem( g(1,:)*[1 state_vector]', 2 );
   [out_1, state_1] = encode_bit(g, a_k, state_vector);
   out_1(1) = 1;
   next_out0(state,:) = 1-2*[out_0 out_1];
   next_out1(state,2*out_0(2)+1:2*out_0(2)+2) = 1-2*out_0;
   next_out1(state,2*out_1(2)+1:2*out_1(2)+2) = 1-2*out_1;
   next_state0(state,:) = [(int_state(state_0)+1) (int_state(state_1)+1)];
   next_state1(state,out_0(2)+1) = int_state(state_0)+1;
   next_state1(state,out_1(2)+1) = int_state(state_1)+1;
   
end

% find out which two previous states can come to present state
last_state0 = zeros(max_state,2);
last_state1 = zeros(max_state,2);
for bit=0:1
   for state=1:max_state
      last_state0(next_state0(state,bit+1), bit+1)=state;
      last_state1(next_state1(state,bit+1), bit+1)=state;
      last_out0(next_state0(state, bit+1), bit*2+1:bit*2+2) = next_out0(state, bit*2+1:bit*2+2);
      last_out1(next_state1(state, bit+1), bit*2+1:bit*2+2) = next_out1(state, bit*2+1:bit*2+2);
   end
end

⌨️ 快捷键说明

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