channel_coding.m
上传用户:look542
上传日期:2009-06-04
资源大小:784k
文件大小:2k
源码类别:

传真(Fax)编程

开发平台:

Matlab

  1. function coded_user_bit = channel_coding( user_bit,ChCodingMethod,Dec_alg,L_total,Generator,Puncture,...
  2.             N_iter,RateChCoding,Alpha,Turbo_frame,N_Turbo_frame,UserRS_Coding ,UserTrellis,...
  3.             TraceBackLen,turn_on )
  4.         
  5. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  6. % 根据不同用户的信道编码参数,进行信道编码
  7. % 输入: user_bit, 用户比特
  8. %       UserRS_Coding, 每个用户的RS码参数
  9. %       UserTrellis,每个用户的卷积码trellis 结构体
  10. %       TraceBackLen, 卷积码译码深度
  11. %       turn_on, 是否打开此功能
  12. % 输出: coded_user_bit, 已编码的用户比特
  13. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  14. if turn_on
  15.     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  16.     % 使用Turbo码 + 交织 
  17.     if ChCodingMethod == 1
  18.         % 先假设单用户情况
  19.         bits = user_bit{1}';
  20.         turbo_coded = zeros( 1,L_total/RateChCoding * N_Turbo_frame);
  21.         
  22.         for n = 1:N_Turbo_frame
  23.             bit_frame = bits( (n-1)*Turbo_frame + 1:n*Turbo_frame );
  24.             en_output = encoderm( bit_frame, Generator, Alpha, Puncture ); 
  25.             turbo_coded(1, (n-1)*L_total/RateChCoding + 1:n*L_total/RateChCoding ) = en_output ;
  26.         end
  27.         
  28.         coded_user_bit{1} = turbo_coded' ;
  29.         
  30.         
  31.         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  32.     % 使用卷积 + RS + 交织    
  33.     elseif ChCodingMethod == 2
  34.         N_user = size( UserRS_Coding ,2);
  35.         for u = 1:N_user
  36.             user_rscode{u} = rsenco(user_bit{u} ,UserRS_Coding(1,u),UserRS_Coding(2,u));
  37.             user_rscode2{u} = [ user_rscode{u} ; zeros( TraceBackLen , 1)];
  38.             user_convcode{u} = convenc(user_rscode2{u},UserTrellis(u));
  39.             
  40.         end   
  41.         coded_user_bit = user_convcode;
  42.     end
  43.     
  44. else
  45.     coded_user_bit = user_bit;
  46. end