chilg_test.m
上传用户:xinxin4122
上传日期:2013-04-03
资源大小:464k
文件大小:2k
源码类别:

邮电通讯系统

开发平台:

Matlab

  1. clear all;
  2. close all;
  3. min_snr=0;
  4. max_snr=40;
  5. step_snr=2;
  6. frame_num=500;
  7. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  8. L=3;
  9. var0=(1-exp(-1))/(1-exp(-L));
  10. ll=0:L-1;
  11. pdp=var0.*exp(-ll);
  12. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  13. snr=min_snr:step_snr:max_snr;
  14. bits_total=64*frame_num;
  15. randn('state',0);
  16. table=[-1 1]; %调制用
  17. err=zeros(1,length(snr));
  18. for snrIndex=1:length(snr);
  19.     last=[0;0];
  20.     for ii=1:frame_num
  21.         data=randn(1,64)>0;
  22.         x=table(data+1); % 星座点映射
  23.         hint1=sqrt(pdp(1))*1/sqrt(2)*(randn(1,1)+i*randn(1,1));
  24.         hint2=sqrt(pdp(2))*1/sqrt(2)*(randn(1,1)+i*randn(1,1));
  25.         hint3=sqrt(pdp(3))*1/sqrt(2)*(randn(1,1)+i*randn(1,1));
  26.         ll=eye(80);
  27.         % 产生三径Rayleigh信道
  28.         channel1=hint1*ll;
  29.         channel2=hint2*ll;
  30.         channel3=hint3*ll;
  31.         hint=[hint1 hint2 hint3];
  32.         H_f=fft(hint,64);
  33.         m=(ifft(x)).';
  34.         
  35.         cp_m=[m(end-16+1:end); m];
  36.         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  37.         % 一个ofdm符号抽样的平均功率
  38.         n=mean(abs(cp_m).^2);
  39.         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  40.         % 平均功率归一化
  41.         cp_m=cp_m/sqrt(n);
  42.         sigma=1/10.^(snr(snrIndex)/10);
  43.         % 通过信道
  44.         cp_mmm=[last; cp_m];
  45.         yy=channel1*cp_mmm(end-79:end)+channel2*cp_mmm(end-80:end-1)+channel3*cp_mmm(end-81:end-2)+sqrt(sigma)*1/sqrt(2)*(randn(1,80)+i*randn(1,80)).';
  46.         last=cp_mmm(end-1:end);
  47.         % 恢复信号功率
  48.         yy=yy*sqrt(n);
  49.         
  50.         % 去除cp
  51.         yy=yy(17:end).';
  52.         tt=fft(yy);
  53.         % 频域均衡
  54.         tt=tt./H_f;
  55.         bits=real(tt)>0;
  56.         err(snrIndex)=err(snrIndex)+sum(data~=bits);
  57.     end
  58. end
  59. aveBer=err/bits_total;
  60. figure(1);
  61. semilogy(snr,aveBer);
  62. axis([min_snr max_snr 10.^-5 1]);
  63. grid on;
  64.