⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qpskzlpbeifen.m

📁 使用matlab程序实现了由随机序列到码元电平、m序列直接扩频解扩、qpsk调制解调
💻 M
字号:
function qpskzlp
clear all
close all
N=20;                                  %随机数点数20
td=0.1;
f0=3000;
wc=2e4*pi;
x=randint(1,N,[0,1]);
g=100;                                 %一个矩形电平采样点

%并串转换
z=reshape(x,2,N/2);                    %并串转换
a=z(1,:);
b=z(2,:);
figure(1);
subplot(311);
stem(x,'LineWidth',1.5);grid on;
subplot(312);
stem(a,'LineWidth',1.5);grid on;
subplot(313);
stem(b,'LineWidth',1.5);grid on;
y1=dpxs(g,a);                          %I通道脉冲形式
y2=dpxs(g,b);                          %Q通道脉冲形式
connections =[1 0 0 1]; 
mseq = m_sequence(connections);        %m序列
m=dpxs(100,mseq);                      %m序列脉冲形式

figure(2);
subplot(311);
t=linspace(0,td,length(y1));
plot(t,y1,'LineWidth',1.5);grid on;
title('I Channel');
axis([0 td -1.5 1.5]);                 %画I通道电平 
subplot(312);
t=linspace(0,td,length(y2));
plot(t,y2,'LineWidth',1.5);grid on;
title('Q Channel');
axis([0 td -1.5 1.5]);                 %画Q通道电平
subplot(313);
t=linspace(0,(td*2)/N,length(m)); 
plot(t,m,'LineWidth',1.5);grid on;
title('m sequence pulse'); 
axis([0 td -1.5 1.5]);                 %画m序列电平
 
%扩频 
out1=kuopinzlp1(N,a);                   %I通道扩频
out2=kuopinzlp1(N,b);                   %Q通道扩频

figure(3);
subplot(211);
t=linspace(0,td,length(out1));
plot(t,out1,'LineWidth',1.5);grid on;
title(' I spread spectrum pulse');
axis([0 td -1.5 1.5]);                 %画I通道扩频图
subplot(212);
plot(t,out2,'LineWidth',1.5);grid on;
axis([0 td -1.5 1.5]);
title('Q spread spectrum pulse');      %画Q通道扩频

%载波调制 
y3=(-1)*sin(2*f0*pi*t).*out1;          %I通道调制
y4=cos(2*f0*pi*t).*out2;               %Q通道调制
y=y3+y4;                               %QPSK调制

figure(4);
subplot(311);
t=linspace(0,td,length(out1));
plot(t,y3,'LineWidth',1.5);grid on;
title('I Channel Modulation');
axis([0 td -1.5 1.5]);                 %画I通道调制图
subplot(312);
plot(t,y4,'LineWidth',1.5);grid on;
title('Q Channel Modulation');
axis([0 td -1.5 1.5]);                 %画Q通道调制图
subplot(313);
plot(t,y,'LineWidth',1.5);grid on;
title('QPSK Modulation'); 
axis([0 td -1.5 1.5]);                 %画QPSK调制图

%射频调制、解调
t=linspace(0,td,length(y));
f1=y.*cos(wc*t);                       %射频调制发射
[f,yf]=T2F(t,y);                       %QPSK调制频域
[f,f1f]=T2F(t,f1);                     %射频调制频域
r=f1.*cos(wc*t);                       %射频解调
[f,rf]=T2F(t,r);                       %射频解调接收频域
[t,l]=lpf(f,rf,3*f0);                  %经过低通滤波
figure(5);
subplot(321);
plot(f,abs(yf),'LineWidth',1.5);
title('QPSK Modulation fdomain');
grid on;                               %QPSK调制频域图
subplot(322);
plot(t,f1,'LineWidth',1.5);
title('fc modulation transmmit');
grid on;                               %画射频调制发射图
subplot(323);
plot(f,abs(f1f),'LineWidth',1.5);
title('fc Modulation fdomain');
grid on;                               %画射频调制发射频域图
subplot(324);
plot(t,r,'LineWidth',1.5);
title('fc demodulation receive ');
grid on;                               %画射频解调接收图
subplot(325);
plot(f,abs(rf),'LineWidth',1.5);
title('fc demodulation recieve fdomain');
grid on;                               %画射频解调接收频域图
subplot(326);
plot(t,l,'LineWidth',1.5);
title('lowfliter ');grid on;           %画经过低通滤波后的图

%载波解调
liremod=(-1)*sin(2*f0*pi*t).*l;        %I通道解调
[f,lif]=T2F(t,liremod);
[t,iremod]=lpf(f,lif,f0);              %经过低通滤波
iremodo=sign(iremod);                  %波形整形
lqremod=cos(2*f0*pi*t).*l;             %Q通道解调              
[f,lqf]=T2F(t,lqremod); 
[t,qremod]=lpf(f,lqf,f0);              %%经过低通滤波
qremodo=sign(qremod);                  %波形整形

t=linspace(0,td,length(l));
figure(6);
subplot(321);
plot(t,liremod,'LineWidth',1.5);
title('I remodulation');
grid on;                               %画I通路解调图
subplot(323);
plot(t,iremod,'LineWidth',1.5);
axis([0 td -0.5 0.5]);                 %画经过低通滤波后的图

t=linspace(0,td,length(liremod));
subplot(325);
plot(t,iremodo,'LineWidth',1.5);
grid on;                              
title('I remodulation over');
axis([0 td -1.5 1.5]);                %波行整形图
subplot(322);
plot(t,lqremod,'LineWidth',1.5);
title('Q remodulation');
grid on;                              %画Q通道解调图
subplot(324);
plot(t,qremod,'LineWidth',1.5);
axis([0 td -0.5 0.5]);                %画经过低通滤波后的图
t=linspace(0,td,length(lqremod));
subplot(326);
plot(t,qremodo,'LineWidth',1.5);
grid on;
title('Q remodulation over');      
axis([0 td -1.5 1.5]);                %波行整形图

%解扩
s=length(m);
for i=1:N/2
  for j=1:s
      ij((i-1)*s+j)=iremodo((i-1)*s+j)*m(j);
  end;
end;                                   %将I路解调结果与m相关
for i=1:N/2
    ijsum=0;
  for j=1:s
      ijsum=ij((i-1)*s+j)+ijsum;
  end;
  if(ijsum>=1000);
     ij1(i)=1;
  else
  if(ijsum<=-1000);
     ij1(i)=-1;  
  end;
  end;
end                                  %根据相关值判决1、-1
ij2=dpxs(g,ij1);
t=linspace(0,td,length(ij2));
figure(7);
subplot(211);
plot(t,ij2,'LineWidth',1.5);
grid on;
title('I Channel jiekuo');
axis([0 td -1.5 1.5]);               %画I通道解扩图
                                    
for i=1:N/2
  for j=1:s
      qj((i-1)*s+j)=qremodo((i-1)*s+j)*m(j);
  end;
end;                                %将Q路解调结果与m相关
for i=1:N/2
    qjsum=0;
  for j=1:s
      qjsum=qj((i-1)*s+j)+qjsum;
  end;
  if(qjsum>=1000);
     qj1(i)=1;
  else
  if(qjsum<=-1000);
     qj1(i)=-1;  
  end;
  end;
end                                %根据相关值判决1、-1
  qj2=dpxs(g,qj1);
t=linspace(0,td,length(qj2));
subplot(212);
plot(t,qj2,'LineWidth',1.5);
grid on;
title('Q Channel jiekuo');
axis([0 td -1.5 1.5]);              %画Q通道解扩图

%串并转换
ij1_uni=bi_to_uni(ij1);             %I路解扩结果变单极性         
qj1_uni=bi_to_uni(qj1);             %Q路解扩结果变单极性  
ij1_qj1=[ij1_uni;qj1_uni];
x1=reshape(ij1_qj1,1,N);            %串并转换
figure(8);
subplot(311);
stem(x1,'LineWidth',1.5);
grid on;
subplot(312);
stem(ij1_uni,'LineWidth',1.5);
grid on;
subplot(313);
stem(qj1_uni,'LineWidth',1.5);
grid on;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -