直接序列扩频Matlab程序
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
直接序列扩频Matlab程序
直接序列扩频通信可以有效地抵抗来自信道中的窄带干扰。在一个直扩通信系统中,扩频是通过伪噪声序列(PN)对发送的信息数据进行调制来实现的。在接收端,原伪噪声序列和所收信号的相关运算可将窄带干扰扩展到DS信号的整个频带,使干扰等效为幅度较低频谱较平
坦的噪声;同时,将DS信号解扩, 恢复原始信息数据。- The direct sequence spread spectrum correspondence may effectively resist from the channel in selective interference. Straight expands in the communications system in, the wide frequency is (PN) carries on through the false noise sequence to the transmission information data modulates realizes. In the receiving end, the original false noise sequence and receives the signal the correlation operation to be possible to expand the selective interference to the DS signal entire frequency band, causes the disturbance equivalent for a scope lower frequency spectrum smoother noise; At the same time, expands the DS signal solution, restores the primary information data.
======================
function [Y]=DSSS(X, mode)
% 完成DSSS调制解调功能
% mode=[1,2]. 1进行调制,2进行解调,未指定时自动完成调制和解调两个功能。
switch nargin
case 0
X='This is a test.';
Y=DSSS(X);
return
case 1
Y1=DSSS(X, 1);
Y2=DSSS(Y1, 2);
Y=Y2;
return;
case 2
if mode==1%调制
D=ones(1,7);
m_sequence=Msequence(D);
X_length=length(X);
ascii_value=abs(X);
ascii_binary=zeros(X_length,7);
%将数据转换为ASCII二进制码
for ii=1:X_length
ascii_binary(ii,:)=Binary(ascii_value(ii));
end
subplot(2,3,1);plot(reshape(ascii_binary,1,X_length*7));title('A:输入数据');
%扩频
Sp_expand=zeros(X_length,127*7);
for ii=1:X_length
for jj=1:7
Sp_expand(ii,127*jj-126:127*jj)=xor(m_sequence,ascii_binary (ii,jj));
end
end
subplot(2,3,2);plot(reshape(Sp_expand,1,X_length*127*7));title('B:数据扩展');
%将扩频码转换为BPSK(1,-1)序列
for ii=1:X_length
for jj=1:127*7
if~(Sp_expand(ii,jj))
Sp_expand(ii,jj)=-1;
end
end
end
Sp_expand_bpsk=reshape(Sp_expand,1,X_length*127*7);
subplot(2,3,3);plot(Sp_expand_bpsk);title('C:BPSK调制')
Y=Sp_expand_bpsk;
elseif mode==2%解调
D=ones(1,7);
m_sequence=Msequence(D);
%将BPSK双极性转换为单极性
l=length(X)/(127*7);
X_length=length(X);
for ii=1:X_length
if X(ii)==-1
X(ii)=0;
end
end
Sp_expand=reshape(X,l,127*7);
subplot(2,3,4);plot(X);title('D:数据传输');
ascii_binary=zeros(l,7);
Demodulate_binary=zeros(l,127*7);
%接收处解调
for ii=1:l
for jj=1:7
Demodulate(ii,127*jj-126:127*jj)=xor(m_sequence,
Sp_expand(ii,127*jj-126:127*jj));
end
end
for ii=1:l
for jj=1:7
ascii_binary(ii,jj)=Demodulate(ii,127*jj-126);
end