demultiplex.m
上传用户:hnyfjx
上传日期:2013-06-30
资源大小:2149k
文件大小:1k
源码类别:

传真(Fax)编程

开发平台:

Matlab

  1. function subr = demultiplex(r, alpha, puncture);
  2. % Copyright 1998, Yufei Wu
  3. % MPRG lab, Virginia Tech.
  4. % for academic use only
  5. % At receiver end, serial to paralle demultiplex to get the code word of each
  6. % encoder
  7. % alpha: interleaver mapping 
  8. % puncture = 0: use puncturing to increase rate to 1/2;
  9. % puncture = 1; unpunctured, rate 1/3;
  10. % Frame size, which includes info. bits and tail bits
  11. L_total = length(r)/(2+puncture);
  12. % Extract the parity bits for both decoders
  13. if puncture == 1        % unpunctured
  14.   for i = 1:L_total  
  15.       x_sys(i) = r(3*(i-1)+1);
  16.       for j = 1:2
  17.           subr(j,2*i) = r(3*(i-1)+1+j);
  18.       end
  19.    end
  20. else            % unpunctured
  21.    for i = 1:L_total
  22.        x_sys(i) = r(2*(i-1)+1);
  23.        for j = 1:2
  24.           subr(j,2*i) = 0;
  25.        end   
  26.        if rem(i,2)>0
  27.           subr(1,2*i) = r(2*i);
  28.        else
  29.           subr(2,2*i) = r(2*i);
  30.        end      
  31.    end
  32. end       
  33. % Extract the systematic bits for both decoders
  34. for j = 1:L_total
  35. % For decoder one
  36.    subr(1,2*(j-1)+1) = x_sys(j);
  37. % For decoder two: interleave the systematic bits  
  38.    subr(2,2*(j-1)+1) = x_sys(alpha(j));
  39. end