CDMA 与 DSSS(直接序列扩频技术)(Matlab代码实现)

👨‍🎓个人主页:研学社的博客     

💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码实现


💥1 概述

所谓直接序列扩频, 就是在发端直接用具有高码率的扩频码序列对信息比特流进行调制, 从而扩展信号的频谱, 在接收端, 用与发送端相同的扩频码序列进行相关解扩, 把展宽的扩频信号恢复成原始信息。一种直接序列扩频技术是使用异或运算将数字信息流与扩展码位流结合起来.

例如说在发射端将"1"用11000100110,而将"0"用00110010110去代替,这个过程就实现了扩频,而在接收机处只要把收到的序列是11000100110就恢复成"1"是00110010110就恢复成"0",这就是解扩。这样信源速率就被提高了11倍,同时也使处理增益达到10dB以上,从而有效地提高了整机倍噪比。

本代码模拟不同用户的N个移动站的传输。使用线性反馈移位寄存器模拟DSSS系统生成PN序列的性能传输模式为QPSK-DSSS。QPSK将由相位分量和四相分量2个阵列组成。

📚2 运行结果

主函数部分代码:

clc
clear;
close all;
​
%Requirements
%1)Generate the QPSK sequences (�1 � j) of N = 4 users, each composed of randomly generated K = 5 symbols
N=4;
K=5;
randSig=zeros(N,K);
​
%QPSK_Inphase=(((randi([0 1],K,1)))*2-1);                      %In-phase symbol generation
%QPSK_Outphase=(((randi([0 1],K,1)))*2-1);                     %Quadrature symbol generation 
for i=1:1:N
       randSig(i,:) = (((randi([0 1],K,1)))*2-1) + 1i*(((randi([0 1],K,1)))*2-1);
end
​
QPSK_Inphase_real = real(randSig);      %In-phase symbol generation
QPSK_Quadphase_img = imag(randSig);     %Quadrature symbol generation
  
 %Another Method%
 
%%% 4 users first we will generate random array of 1 and -1 real
%%% and another random stream of bits for the imaginary part
% Real_N1=randi([-1 ,1],1,5);
% Real_N1(~Real_N1)=-1; %%%%%%%% to convert any zero to -1 
% Real_N2=randi([-1 ,1],1,5);
% Real_N2(~Real_N2)=-1;
% Real_N3=randi([-1 ,1],1,5);
% Real_N3(~Real_N3)=-1;
% Real_N4=randi([-1 ,1],1,5);
% Real_N4(~Real_N4)=-1;
% Imag_N1=randi([-1 ,1],1,5);
% Imag_N1(~Imag_N1)=-1; %%%%%%%% to convert any zero to -1 
% Imag_N2=randi([-1 ,1],1,5);
% Imag_N2(~Imag_N2)=-1;
% Imag_N3=randi([-1 ,1],1,5);
% Imag_N3(~Imag_N3)=-1;
% Imag_N4=randi([-1 ,1],1,5);
% Imag_N4(~Imag_N4)=-1;
% for i=1:1:5    %%%%%%%%% to generate the QPSK Sequence
% N1(i)=(Real_N1(i)+j*Imag_N1(i));
% N2(i)=(Real_N2(i)+j*Imag_N2(i));
% N3(i)=(Real_N3(i)+j*Imag_N3(i));
% N4(i)=(Real_N4(i)+j*Imag_N4(i));
% end
%  disp(N1)
%  disp(N2)
%  disp(N3)
%  disp(N4)
%  
 %%%
 
 
%2)Generate the maximal length spreading codes for the N users (i.e. N= 4 users)
Maximal_length=7;   %Length: 7, 15 and 63 enter it manually or using 
%another method
%Maximal_length = input("enter maximal length: ");
% while (Maximal_length ~=7 && Maximal_length ~=15 && Maximal_length ~=63)
%     Maximal_length = input("Renter maximal length: ");
% end
if Maximal_length == 7
   % disp("test 7");     %for debug
    PN_Spreaded_Sequence_in=zeros(N,Maximal_length);
    PN_Spreaded_Sequence_quad=zeros(N,Maximal_length);
    Genrator_Polynomial=[3 2 0];
    for i=1:1:N     %%%%
        h_in =commsrc.pn('GenPoly',Genrator_Polynomial,'Shift',i,'NumBitsOut',Maximal_length);
        h_quad=commsrc.pn('GenPoly',Genrator_Polynomial,'Shift',i+N,'NumBitsOut',Maximal_length);
        %Another method: different initial state for each iteration so that
        %we can get shifted
      
        PN_Spreaded_Sequence_in(i,:)=generate(h_in);
        PN_Spreaded_Sequence_quad(i,:)=generate(h_quad);
    end
elseif Maximal_length == 15
   % disp("test 15");    %for debug
    PN_Spreaded_Sequence_in=zeros(N,Maximal_length);
    PN_Spreaded_Sequence_quad=zeros(N,Maximal_length);
    Genrator_Polynomial=[4 3 0];
    for i=1:1:N
        h_in =commsrc.pn('GenPoly',Genrator_Polynomial,'Shift',i,'NumBitsOut',Maximal_length);
        h_quad=commsrc.pn('GenPoly',Genrator_Polynomial,'Shift',i+N,'NumBitsOut',Maximal_length);
        %Another method: different initial state for each iteration so that
        %we can get shifted
        
        PN_Spreaded_Sequence_in(i,:)=generate(h_in);
        PN_Spreaded_Sequence_quad(i,:)=generate(h_quad);
    end
elseif Maximal_length == 63
   % disp("test 63");    %for debug
    PN_Spreaded_Sequence_in=zeros(N,Maximal_length);
    PN_Spreaded_Sequence_quad=zeros(N,Maximal_length);
    Genrator_Polynomial=[6 5 0];
    for i=1:1:N
        h_in =commsrc.pn('GenPoly',Genrator_Polynomial,'Shift',i,'NumBitsOut',Maximal_length);
        h_quad=commsrc.pn('GenPoly',Genrator_Polynomial,'Shift',i+N,'NumBitsOut',Maximal_length);
        %Another method: different initial state for each iteration so that
        %we can get shifted
        
        PN_Spreaded_Sequence_in(i,:)=generate(h_in);
        PN_Spreaded_Sequence_quad(i,:)=generate(h_quad);
    end
end
​
PN_Spreaded_Sequence_in(PN_Spreaded_Sequence_in==0)=-1;
PN_Spreaded_Sequence_quad(PN_Spreaded_Sequence_quad==0)=-1;
​
​
%3) Spread the signal by multiplying each QPSK symbol with the spreading code
Spreaded_Signal_InPhase_real = zeros(N,K*Maximal_length);
Spreaded_Signal_Quad_img = zeros(N,K*Maximal_length);
for i=1:1:N
    %Note that each of the in-phase and quadrature-phase components will be multiplied by a separate spreading code
    %in-phase component
    Spreaded_Signal_InPhase_real(i,:)=kron(QPSK_Inphase_real(i,:),PN_Spreaded_Sequence_in(i,:));
    %quadrature-phase component
    Spreaded_Signal_Quad_img(i,:)=kron(QPSK_Quadphase_img(i,:),PN_Spreaded_Sequence_quad(i,:));
    
end

🎉3 参考文献

[1]李群. 脉冲成形DSSS及DS-CDMA信号参数盲估计研究[D].重庆邮电大学,2019.

部分理论引用网络文献,若有侵权联系博主删除。

🌈4 Matlab代码实现

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

荔枝科研社

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值