end
semilogy(SNRindB2,theo_err_prb,'b:'); %绘图函数 %ds_t.m 扩频通信系统在抑制干扰方面的分析图 ⑵M-文件
function [p]=ds_ty(snr_in_dB,A,w)
%ds_ty.m 扩频通信系统在抑制干扰方面的仿真 %snr_in_dB 信噪比 %p 误码率
%A 正弦干扰幅度 %w 正弦干扰角频率
%PN码采用长度Lc为30的gold码 snr=10^(snr_in_dB/10); sgma=1;
Eb=2*sgma^2*snr;
N=10^4; %仿真序列长度10^4,运行时间约3分钟 p=0;
gold=[0 1 1 1 0 0 0 0 1 0 0 0 0 1 1 0 0 1 0 0 1 0 1 1 1 1 0 0 0 0 0]; Lc=length(gold); %Lc=30; pn_seq=2*gold-1; E_chip=Eb/Lc; temp=0; data=0;
repeated_data=zeros(1,Lc); trans_sig=zeros(1,Lc); noise=zeros(1,Lc); n=1:Lc;
interference=zeros(1,Lc); rec_sig=zeros(1,Lc); temp=zeros(1,Lc); decision_variable=0; decision=0; num_of_err=0; time=0; for i=1:N
temp=rand; if (temp<0.5) data=-1;
沈阳大学毕业设计(论文) No 34
else
data=1; end
for j=1:Lc
repeated_data(j)=data; end
trans_sig=sqrt(E_chip)*repeated_data.*pn_seq; noise=sgma*randn(1,Lc); time=time+1,
n=(time-1)*Lc+1:time*Lc; interference=A*sin(w*n);
rec_sig=trans_sig+noise+interference; temp=rec_sig.*pn_seq;
decision_variable=sum(temp); if (decision_variable<0) decision=-1; else
decision=1; end
if (decision~=data)
num_of_err=num_of_err+1; end end
num_of_err,
p=num_of_err/N;
%ds_ty.m扩频通信系统在抑制干扰方面的仿真分析
沈阳大学毕业设计(论文) No 35
附录2 直扩-SIMILINK动态仿真模框图
图16直序扩频(先调制后扩频)系统框图
沈阳大学毕业设计(论文) No 36
图17 随机整数发生器产生的信号频谱分析图
图18 经M-PSK调制后的频谱图
沈阳大学毕业设计(论文) No 37
图19 经PN序列发生器扩频后的频谱图
图20 传输过程加入噪声后的频谱图
沈阳大学毕业设计(论文) No 38
图21 接收部分经PN序列解扩后的频谱
图22 解调后的频谱图
沈阳大学毕业设计(论文) No 39