登录后复制
clc;clear;close all; encod1=round(rand(1,5000)); %产生5000个随机码元encod1=2*encod1-1; %码序列变为双极性 L=length(encod1); for m=128 %扩频因子128倍 a=repmat(encod1,1,m); b=(reshape(a,L,m)).'; x=reshape(b,1,L*m); len=length(x); %产生M序列 g=19;state=11;N=len; gen=dec2bin(g)-48; M=length(gen); curState=dec2bin(state,M-1)-48;for k=1:N A(k)=curState(M-1); a=rem(sum(gen(2:end).*curState),2); curState=[a curState(1:M-2)];end x_code=sign(A-0.5); %Ex 1 绘制M自相关 ac_x=conv(x_code,x_code(len:-1:1))/len; figure;plot(ac_x(len:end));grid on; axis([0 63 -0.3 1.2]);title('m序列自相关序列') msout=x.* x_code; % 已扩频信号 % QPSK 调制,2bit信息映射到一个星座点,并对输出符号归一化N=length(msout);msout=(msout+1)/2;lrem=rem(N,2);if lrem~=0 msout(N+1:N+(2-lrem))=0;endNN=length(msout);qam_sig = zeros(1,NN/2);d = sqrt(2)/2; %所采用的星座图进行能量归一化 GrayMap = [d -d]; %对应的I,Q比特为[0 1]for i1=0:2:NN-1 %4bit为一组 site_I = msout(i1+1);%每组中的第一比特为I分量 site_Q = msout(i1+2);%每组中的第二比特为Q分量 qam_sig(i1/2+1) = GrayMap(site_I+1)+1i*GrayMap(site_Q+1);end for condition=1:4 %信道噪声 for SNR1=-20:-10 Eb = 1; N0= Eb/(10^((SNR1)/10)); sig=qam_sig+sqrt(N0/2)*randn(size(qam_sig))+sqrt(N0/2)*randn(size(qam_sig))*1i; %加单音、多音、部分带干扰 switch condition case 1 case 2 band=1;%控制干扰带宽 for jj=1:L for kk=1:band interfere=2*rand(1)-1; sig(jj*(m/2)-(m/2)+kk)=sqrt(2)/2*interfere+sqrt(2)/2*1i*interfere; end end case 3 band=5;%控制干扰带宽 for jj=1:L for kk=1:band interfere=2*rand(1)-1; sig(jj*(m/2)-(m/2)+kk)=sqrt(2)/2*interfere+sqrt(2)/2*1i*interfere; end end case 4 band=15;%控制干扰带宽 for jj=1:L for kk=1:band interfere=2*rand(1)-1; sig(jj*(m/2)-(m/2)+kk)=sqrt(2)/2*interfere+sqrt(2)/2*1i*interfere; end end end1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.
2014a
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删