chilg_test.m
上传用户:xinxin4122
上传日期:2013-04-03
资源大小:464k
文件大小:2k
- clear all;
- close all;
- min_snr=0;
- max_snr=40;
- step_snr=2;
- frame_num=500;
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- L=3;
- var0=(1-exp(-1))/(1-exp(-L));
- ll=0:L-1;
- pdp=var0.*exp(-ll);
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- snr=min_snr:step_snr:max_snr;
- bits_total=64*frame_num;
- randn('state',0);
- table=[-1 1]; %调制用
- err=zeros(1,length(snr));
- for snrIndex=1:length(snr);
- last=[0;0];
- for ii=1:frame_num
- data=randn(1,64)>0;
- x=table(data+1); % 星座点映射
- hint1=sqrt(pdp(1))*1/sqrt(2)*(randn(1,1)+i*randn(1,1));
- hint2=sqrt(pdp(2))*1/sqrt(2)*(randn(1,1)+i*randn(1,1));
- hint3=sqrt(pdp(3))*1/sqrt(2)*(randn(1,1)+i*randn(1,1));
- ll=eye(80);
- % 产生三径Rayleigh信道
- channel1=hint1*ll;
- channel2=hint2*ll;
- channel3=hint3*ll;
- hint=[hint1 hint2 hint3];
- H_f=fft(hint,64);
- m=(ifft(x)).';
-
- cp_m=[m(end-16+1:end); m];
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 一个ofdm符号抽样的平均功率
- n=mean(abs(cp_m).^2);
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 平均功率归一化
- cp_m=cp_m/sqrt(n);
- sigma=1/10.^(snr(snrIndex)/10);
- % 通过信道
- cp_mmm=[last; cp_m];
- 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)).';
- last=cp_mmm(end-1:end);
- % 恢复信号功率
- yy=yy*sqrt(n);
-
- % 去除cp
- yy=yy(17:end).';
- tt=fft(yy);
- % 频域均衡
- tt=tt./H_f;
- bits=real(tt)>0;
- err(snrIndex)=err(snrIndex)+sum(data~=bits);
- end
- end
- aveBer=err/bits_total;
- figure(1);
- semilogy(snr,aveBer);
- axis([min_snr max_snr 10.^-5 1]);
- grid on;
-