• PUDN用户
    了解作者
  • matlab
    开发工具
  • 4KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 7
    下载次数
  • 2009-11-26 12:44
    上传日期
衰落信道下QPSK的特性,设置好参数后再调用几个子程序,仿真QPSK的误码率性能
QPSKfade.rar
  • QPSKfade
  • qpskfading.m
    3.9KB
  • delay.m
    743B
  • fade.m
    2.1KB
  • sefade.m
    1.7KB
内容介绍
% % QPSK % Simulation program to realize transmission system % clear all; clc; tic; %******************** Preparation part ********************** sr=256000.0; % Symbol rate ml=2; % ml:Number of modulation levels (BPSK:ml=1, QPSK:ml=2, 16QAM:ml=4) nd = 1000000; % Number of symbols that simulates in each loop ebn0=[1 2 3 4 5 6 7 8 9 10]; % Eb/N0 IPOINT=8; % Number of oversamples %******************* Fading initialization ******************** % Time resolution tstp=1/sr/IPOINT; % direct wave. itau = [0]; % direct wave. dlvl = [0]; % In normal case, more than six waves are needed to generate Rayleigh fading n0=[6]; % Initial Phase of delayed wave In this simulation four-path Rayleigh fading are considered. th1=[0.0]; % Number of fading counter to skip itnd0=nd*IPOINT*100; % Initial value of fading counter itnd1=[1000]; % In this simulation one-path Rayleigh fading are considered now1=1; % Maximum Doppler frequency [Hz] fd=160; % (1->flat (only amplitude is fluctuated),0->nomal(phase and amplitude are fluctutated) flat =1; %******************** START CALCULATION ********************* nloop=10; % Number of simulation loops ber=zeros(1,10); factor=0.5; % snr=zeros(1,10); for iii=1:nloop %******************** Data generation ******************************** data=rand(1,nd*ml)>0.5; % rand: built in function %******************** QPSK Modulation *********************** % [ich,qch]=qpskmod(data,1,nd,ml); data1=data.*2-1; % num=1; data2=reshape(data1,2,nd); ich=data2(1,:); qch=data2(2,:); outdata=ich+j*qch; %****************** Attenuation Calculation ***************** n0=sqrt(factor*10^(-ebn0(iii)/10)); % snr(iii)=10*log10(ebn0(iii)); % n0(iii)=sqrt(factor*10^(-snr(iii)/10)); %********************** Fading channel ********************** % Generated data are fed into a fading simulator [ifade,qfade]=sefade(ich,qch,itau,dlvl,th1,n0,itnd1,now1,length(ich),tstp,fd,flat); % Updata fading counter itnd1 = itnd1+ itnd0; outdata1=ifade+j*qfade; %************ Add White Gaussian Noise (AWGN) *************** %[ich3,qch3]= comb(ifade,qfade,attn);% add white gaussian noise noise=(randn(1,length(ifade))+j*randn(1,length(qfade))).*n0; outdata2=outdata1+noise; %******************** QPSK Demodulation ********************* %maximum likelihood detection value=[1+j;1-j;-1+j;-1-j]; valspr=repmat(value,1,nd); outdata3=repmat(outdata2,4,1); minus=outdata3-valspr; [dist,pla]=min(abs(minus),[],1); value=reshape(value,1,4); % row vector recedata=(value(pla)); % demodata=zeros(1,nd*ml); %for jj=1:nd % re=real(recedata); % im=imag(recedata); % signal=[0 0 1 0 1 1 0 1]; % if re>0 & im>0 % demodata(2*jj-1)=signal(1); % demodata(2*j)=signal(2); % elseif re<0 & im>0 % demodata(2*jj-1)=signal(3); % demodata(2*j)=signal(4); % elseif re<0 & im<0 % demodata(2*jj-1)=signal(5); % demodata(2*j)=signal(6); % else % demodata(2*jj-1)=signal(7); % demodata(2*jj)=signal(8); % end %end demodata=zeros(1,ml*nd); ich1=real(recedata); qch1=imag(recedata); demodata(1,(1:ml:ml*nd-1))=ich1(1,1:nd)>=0; demodata(1,(2:ml:ml*nd))=qch1(1,1:nd)>=0; %******************** Bit Error Rate (BER) ****************** noe0=xor(data,demodata); % sum: built in function % noe1=min(noe0,1); noe=sum(noe0); nod=length(data); % length: built in function ber(iii)=noe/nod; n=iii end % for iii=1:nloop %********************** Output result *************************** semilogy(ebn0,ber,'*-'); title('QPSK performance of BER'); xlabel('EB/N0'); ylabel('BER'); grid; toc; %******************** end of file *****************************8*
评论
    相关推荐