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

📄 encoderm.m

📁 放大转发协同通信的有关仿真代码
💻 M
字号:
function en_output = encoderm( x, g, alpha, puncture )
% Copyright Nov. 1998 Yufei Wu
% MPRG lab, Virginia Tech.
% for academic use only

% uses interleaver map 'alpha'
% if puncture = 1, unpunctured, produces a rate 1/3 output of fixed length
% if puncture = 0, punctured, produces a rate 1/2 output 
% multiplexer chooses odd check bits from RSC1 
% and even check bits from RSC2

% determine the constraint length (K), memory (m) 
% and number of information bits plus tail bits.

[n,K] = size(g); 
m = K - 1;
L_info = length(x); 
L_total = L_info + m;  

% generate the codeword corresponding to the 1st RSC coder
% end = 1, perfectly terminated;
input = x;
output1 = rsc_encode(g,input,1);    % why 1? terminated?  --yzh

% make a matrix with first row corresponing to info sequence
% second row corresponsing to RSC #1's check bits.
% third row corresponsing to RSC #2's check bits.

y(1,:) = output1(1:2:2*L_total);    % y: unpuncture output of encoder; y(1,:) has m bits more than input bits   -yzh
y(2,:) = output1(2:2:2*L_total);


% interleave input to second encoder
for i = 1:L_total
   input1(1,i) = y(1,alpha(i));     %alpha--index of interleaver,   --yzh
end
output2 = rsc_encode(g, input1(1,1:L_total), -1 );  %input has been interleaved. L_total bits already.(see y(1,:)) so unterminated  --yzh
y(3,:) = output2(2:2:2*L_total);

% paralell to serial multiplex to get output vector
% puncture = 0: rate increase from 1/3 to 1/2;
% puncture = 1; unpunctured, rate = 1/3;


if puncture > 0		% unpunctured
   for i = 1:L_total
       for j = 1:3
           en_output(1,3*(i-1)+j) = y(j,i); % put the 3 bits of the same colomn to a sequential outputs  -yzh
       end
   end
else			% punctured into rate 1/2
   for i=1:L_total
       en_output(1,n*(i-1)+1) = y(1,i);
       if rem(i,2)  % output check bits by turns    -yzh
      % odd check bits from RSC1
          en_output(1,n*i) = y(2,i);
       else
      % even check bits from RSC2
          en_output(1,n*i) = y(3,i);
       end 
    end  
end

% antipodal modulation: +1/-1
en_output = 2 * en_output - ones(size(en_output));



⌨️ 快捷键说明

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