user_bit_gen.m
上传用户:gzcxg999
上传日期:2021-07-15
资源大小:190k
文件大小:1k
源码类别:

matlab例程

开发平台:

CHM

  1. function [user_bit,user_bit_cnt]  = user_bit_gen( N_user, N_data ,N_sym , Modulation )
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. % 功能:       产生不同用户的发送比特
  4. %           用cell结构体封装不同用户的数据,因为cell结构体的矩阵元素可以维数不同
  5. % 输入:     N_user,用户数
  6. %           N_data,数据子载波数 
  7. %           N_sym,本帧OFDM符号数
  8. %           Modulation, 调制方式
  9. % 输出:     user_bit, 每个用户的比特序列,为cell结构
  10. %           user_bit_cnt, 每个用户的序列长度
  11. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  12. % 每个用户在一个OFDM符号期间发送的比特数
  13. user_bit_tmp = cell( 1,N_user );
  14. bit_per_sym = Modulation * N_data;
  15. % 可以选择用户比特分布为:
  16. % 1) 所有用户比特相同。 
  17. bit_cnt_sym = repmat(bit_per_sym/N_user,1,N_user);
  18. % 2) 用户按照比例 (1:N_user)/((1 + N_user)*N_user/2) 发送比特数据
  19. % 目的是为了仿真不同用户的信息比特长度不同的情况,也可以修改得到其他的用户数据比例
  20. % bit_cnt_sym = round( [1:N_user]/((1 + N_user)*N_user/2) * bit_per_sym );
  21. user_bit_cnt = bit_cnt_sym * N_sym ;
  22. for u = 1:N_user 
  23.     user_bit_tmp{u} = rand (  user_bit_cnt(u) ,1 ) > 0.5 ;
  24. end
  25. user_bit = user_bit_tmp;