目录
💥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.
部分理论引用网络文献,若有侵权联系博主删除。