• 大小: 2KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-16
  • 语言: Matlab
  • 标签: QPSK  MATLAB  

资源简介

QPSK的MATLAB仿真代码,包括QPSK的随机数生成,调制,解调,星座图,

资源截图

代码片段和文件信息

clear all;
clc;
num=100;                                  %原始信息序列长度
samp=100;                                 %采样点数
delta_T=1/samp;                           %采样间隔
N=samp*num;                               %总的采样点数
msg_orig=randint(1num);                  %序列生成
data1=2*msg_orig-1;                       %单/双极性变换

ry_I=raylrnd(0.81num/2);                %以0.8为参数的瑞利衰落
ry_Q=raylrnd(0.81num/2);                %以0.8为参数的瑞利衰落

for i=1:num
    data1_orig(samp*(i-1)+1:samp*i)=data1(i);%对data1进行采样
end
for i=1:2000
    data(i)=data1_orig(i);
end
%--------------------------------------------画信源及频谱图-----------------------

figure(1);
subplot(212);                              
pwelch(data1_orig[][][]10);              
subplot(211);
x1=0+0.01:0.01:100;
plot(x1data1_orig);                          
axis([0 10 -1.2 1.2]);                       

%----------------------------------将信息源分成两路 ,并对第I路信号抽样-------------
data11=zeros(1samp*num/2);              
for i1=1:num/2  
    data11(samp*(i1-1)+1:samp*i1)=data1(2*i1-1);       %I路信号是信源的第奇数个码元,并对它抽样
end

data12=zeros(1samp*num/2);                            %Q路信号时信源的第偶数个码元,并对其抽样
for i2=1:num/2  
    data12(samp*(i2-1)+1:samp*i2)=data1(2*i2);
end

%------------------------------------------对余弦载波抽样------------------------------
for j1=1:samp*num/2                      
    a1(j1)=cos((j1-1)*2*pi/100);           %每个余弦波每个周期采50个点
end

%------------------------------------------对正弦载波抽样------------------------------
for j2=1:samp*num/2                      
    a2(j2)=sin((j2-1)*2*pi/100);
end

%---------------------------------------------调制------------------------------------
data21=data11.*a1;                              %I路用余弦调制                         
data22=data12.*a2;                              %Q路用正弦调制

%--------------------------------------为两路信号加上瑞利衰落--------------------------
for i=1:num/2
    data21_ray(i)=data21(i)*ry_I(i);
    data22_ray(i)=data22(i)*ry_Q(i);
end

data2_modul=data21+data22;                    %调制后总的信号
data2_ray=data21_ray+data22_ray;              %加瑞利衰落后总的信号

for i=1:1000
    data2_modul_t(i)=data2_modul(i);
end
%-----------------------------------------画调制后的信号波形和频谱图---------------
figure(2);     
subplot(212);
pwelch(data2_modul[][][]10);

subplot(211);
x2=0+0.01:0.01:10;
plot(x2data2_modul_t);


data3=awgn(data2_modul1‘measured‘);           %经过AWGN信道
for i=1:1000
    data3_t(i)=data3(i);
end
%-----------------------------------画经过高斯信道后的信号波形和频谱图----------------------
figure(3);    
subplot(212);
pwelch(data3[][][]10);

subplot(211);
plot(x2data3_t);


%------------------------------------------------星座图-----------------------------------
clear;                                         
N=1000;
s00=[1 0]; s01=[0 -1]; s11=[-1 0]; s10=[0 1];   %  信号映射
SNRindB1=8;
E=1;                                            % 码元能量
snr=10^(SNRindB1/10); 
sgma=sqrt(E/snr)/2; 
for 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        5259  2010-11-06 11:06  QPSK_MOD.m

评论

共有 条评论