QPSK调制解调程序

  • Z9_870017
    了解作者
  • 44.7KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-19 09:40
    上传日期
一个MATLAB仿真的QPSK调制解调程序
qpsk调制解调.rar
内容介绍
% qpsk % qpsk.m % Simulation program to realize QPSK transmission system % (under one path fading) %******************** Preparation part ************************************* sr=256000.0; % Symbol rate ml=2; % ml:Number of modulation levels (BPSK:ml=1, QPSK:ml=2, 16QAM:ml=4) br=sr .* ml; % Bit rate nd = 10; % Number of symbols that simulates in each loop ebn0=10; % Eb/N0 IPOINT=8; % Number of oversamples %*********************************Main loop**************************** for ebn0=0:2:6; %************************* Filter initialization *************************** irfn=21; % Number of taps alfs=0.5; % Rolloff factor [xh] = hrollfcoef(irfn,IPOINT,sr,alfs,1); %Transmitter filter coefficients [xh2] = hrollfcoef(irfn,IPOINT,sr,alfs,0); %Receiver filter coefficients %******************* Fading initialization ******************** % If you use fading function "sefade", you can initialize all of parameters. % Otherwise you can comment out the following initialization. % The detailed explanation of all of valiables are mentioned in Program 2-8. % Time resolution tstp=1/sr/IPOINT; % Arrival time for each multipath normalized by tstp % If you would like to simulate under one path fading model, you have only to set % direct wave. itau = [0]; % Mean power for each multipath normalized by direct wave. % If you would like to simulate under one path fading model, you have only to set % direct wave. dlvl = [0]; % Number of waves to generate fading for each multipath. % 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 % In this simulation one-path Rayleigh fading are considered. % Therefore one fading counter are needed. itnd1=[1000]; % Number of directwave + Number of delayed wave % In this simulation one-path Rayleigh fading are considered now1=1; % Maximum Doppler frequency [Hz] % You can insert your favorite value fd=160; % You can decide two mode to simulate fading by changing the variable flat % flat : flat fading or not % (1->flat (only amplitude is fluctuated),0->nomal(phase and amplitude are fluctutated) flat =1; %******************** START CALCULATION ************************************* nloop=10; % Number of simulation loops noe = 0; % Number of error data nod = 0; % Number of transmitted data for iii=1:nloop %*************************** Data generation ******************************** data1=rand(1,nd*ml)>0.5;% rand: built in function %*************************** QPSK Modulation ******************************** [ich,qch]=qpskmod(data1,1,nd,ml); [ich1,qch1]= compoversamp(ich,qch,length(ich),IPOINT); [ich2,qch2]= compconv(ich1,qch1,xh); %**************************** Attenuation Calculation *********************** spow=sum(ich2.*ich2+qch2.*qch2)/nd; % sum: built in function attn=0.5*spow*sr/br*10.^(-ebn0/10); attn=sqrt(attn); % sqrt: built in function %********************** Fading channel ********************** % Generated data are fed into a fading simulator [ifade,qfade]=Rayleigh_channel(ich2,qch2,itau,dlvl,th1,n0,itnd1,now1,length(ich2),tstp,fd,flat); % Updata fading counter itnd1 = itnd1+ itnd0; %********************* Add White Gaussian Noise (AWGN) ********************** %[ich3,qch3]= comb(ifade,qfade,attn); % add white gaussian noise ich3 = randn(1,length(ifade)).*attn; qch3 = randn(1,length(ifade)).*attn; ich3 = ich3+ifade(1:length(ifade)); qch3 = qch3+qfade(1:length(qfade)); [ich4,qch4]= compconv(ich3,qch3,xh2); syncpoint=irfn*IPOINT+1; ich5=ich4(syncpoint:IPOINT:length(ich4)) qch5=qch4(syncpoint:IPOINT:length(qch4)) %**************************** QPSK Demodulation ***************************** %[demodata]=qpskdemod(ich5,qch5,1,nd,ml); para=1; demodata=zeros(para,ml*nd); demodata((1:para),(1:ml:ml*nd-1))=ich5((1:para),(1:nd))>=0; demodata((1:para),(2:ml:ml*nd))=qch5((1:para),(1:nd))>=0; %************************** Bit Error Rate (BER) **************************** noe2=sum(abs(data1-demodata)); % sum: built in function nod2=length(data1); % length: built in function noe=noe+noe2; nod=nod+nod2; ber(:,iii)=noe2/nod2; %BER of the system fprintf('%d\t%e\n',iii,noe2/nod2); % fprintf: built in function end % for iii=1:nloop berave(:,ebn0/2+1)=sum(ber)/100; %BER for certain ebn0 fprintf('%d\t%e\n',ebn0,berave(:,ebn0/2+1)); %fprintf('%d\t%d\t%d\t%e\n',ebn0,noe,nod,noe/nod); % fprintf: built in function %fid = fopen('BERqpskfad.dat','a'); %fprintf(fid,'%d\t%e\t%f\t%f\t\n',ebn0,noe/nod,noe,nod); % fprintf: built in function %fclose(fid); end %**************Theoretical BER Under AWGN and Rayleigh channel*****************% ebn0=0:2:6; ebn1=0:0.1:6; for i=1:length(ebn1) SNR=exp(ebn1(i)*log(10)/10); % signal to noise ratio theo_err_prb(i)=0.5*erfc(sqrt(SNR)); theo_err_prb2(i)=0.5*(1-1/sqrt(1+1/SNR)); end % %****************Calculation of Signal Spectrum****************** %********************** Output result *************************** % Output of simulated BER and theoretical BER figure(1); semilogy(ebn0,berave,'*'); title('Performance of QPSK'); xlabel('EB/N0(DB)'); ylabel('BER'); hold semilogy(ebn1,theo_err_prb,'r'); semilogy(ebn1,theo_err_prb2); legend('QPSK Rayleigh (simulated)','QPSK AWGN (theroy)','QPSK Rayleigh (theroy)') figure(2); %Input baseband waveform subplot(3,2,1); plot(data1); xlabel('Input baseband waveform'); % Power spectrum of Input subplot(3,2,2); data1_s=abs(fft(data1)); plot(fftshift(data1_s)); xlabel('Power spectrum of Input'); % QPSK modulaed singal subplot(3,2,3); para=1; moddata=zeros(para,ml*nd); moddata((1:para),(1:ml:ml*nd-1))=ich2((1:para),(1:nd)); moddata((1:para),(2:ml:ml*nd))=qch2((1:para),(1:nd)); plot(moddata); xlabel(' QPSK modulaed singal'); % Power spectrum of QPSK modulaed singal subplot(3,2,4); moddata_s=abs(fft(moddata)); plot(fftshift(moddata_s)); xlabel('Power spectrum of QPSK modulaed singal'); % AWGN channel output subplot(3,2,5); data_agwn=zeros(para,ml*nd); data_agwn((1:para),(1:ml:ml*nd-1))=ich3((1:para),(1:nd)); data_agwn((1:para),(2:ml:ml*nd))=qch3((1:para),(1:nd)); plot(data_agwn); xlabel('AWGN channel output'); % Power spectrum of AWGN channel output subplot(3,2,6); plot(abs(fft(data_agwn))); xlabel('Power spectrum of AWGN channel output'); figure(3); subplot(2,1,1); plot(ich2,qch2); subplot(2,1,2); plot(ifade,qfade); %******************** end of file ***************************
评论
    相关推荐
    • Matlab合集
      冈萨雷斯数字图像处理MATLAB版.中文版+数字图像处理第二版中文版(冈萨雷斯)+MATLAB-R2014a完全自学一本通+MATLAB R2016a完全自学一本通 素材文件+[模式识别与智能计算:MATLAB技术实现(第2版)].杨淑莹.扫描版
    • MATLAB教程
      MATLAB教程MATLAB教程MATLAB教程MATLAB教程MATLAB教程MATLAB教程
    • MATLAB
      MATLAB 该项目是在matlab上完成的,涉及创建和移动宇宙飞船和机器人。 太空飞船和机器人是使用Matlab中的简单几何形状创建的,并通过连续变换矩阵进行移动。 这个项目教我如何使用变换矩阵(旋转,平移等)的概念...
    • MATLAB基础
      一本学习matlab的一本好书
    • MATLAB编译器
      基于MATLAB 2018b版本介绍MATLAB编译器。介绍如何利用编译器将MATLAB代码编译为独立应用程序或组件,并在没有安装MATLAB的计算机上进行部署。
    • matlabruntime
      通过奇点容器运行您的matlab项目 可以在没有MATLAB的容器中运行matlab代码。 为此,我们首先需要通过Matlab编译器在本地构建相应的Matlab代码的独立应用程序,然后使用具有Matlab运行时( 的容器)运行该应用程序 )...
    • matlab实现
      matlab实现 matlab实现matlab实现matlab实现matlab实现
    • matlab 教程
      matlab 信号处理资料,里面包含信号处理pdf文档,一些杂乱的程序和命令等
    • matlab教程
      matlab教程,PPT格式,包含 matlab基本知识、matlab入门、matlab作图、线性规划、无约束优化、非线性规划、统计工具箱、差值、微分方程等多项知识点,并且每个知识点独立成为PPT,内还含有matlab信号处理详解等文档...
    • matlab简介
      1.MATLAB 开发环境 1.1 MATLAB 的视窗环境 进入MATLAB之后,会看到一个视窗MATLAB Command Window称为指令视窗,它是你键入指令的地方同时 MATLAB也将计算结果显示在此。 1.2 简易计算 我们先从MATLAB的...