一共四个程序图片被压缩了,下载后放大会很清晰1文件名为digit_baseband.m%数字基带信号的功率谱密度digit_baseband.mclearall;closeall;Ts=1;N_sample=8;%每个码元的抽样点数dt=Ts/N_sample;%抽样时间间隔N=1000;%码元数%T=N*dt;t=0:dt:(N*N_sample-1)*dt;gt1=ones(1,N_sample);%NRZ非归零波形gt2=ones(1,N_sample/2);%RZ归零波形gt2=[gt2zeros(1,N_sample/2)];d=(sign(randn(1,N))+1)/2;data=sigexpand(d,N_sample);%对序列间隔插入N_sample-1个0st1=conv(data,gt1);%调用MATLAB的卷积函数st2=conv(data,gt2);d=2*d-1;%变成双极性序列data=sigexpand(d,N_sample);st3=conv(data,gt1);st4=conv(data,gt2);[f,st1f]=T2F(t,[st1(1:length(t))]);[f,st2f]=T2F(t,[st2(1:length(t))]);[f,st3f]=T2F(t,[st3(1:length(t))]);[f,st4f]=T2F(t,[st4(1:length(t))]);figure(1)subplot(421)plot(t,[st1(1:length(t))]);gridaxis([020-1.51.5]);ylabel('单极性NRZ波形');subplot(422);plot(f,10*log10(abs(st1f).^2/Ts));gridaxis([-55-4040]);ylabel('单极性NRZ功率谱密度(dB/Hz)');subplot(423)plot(t,[st2(1:length(t))]);axis([020-1.51.5]);gridylabel('单极性RZ波形');subplot(424);plot(f,10*log10(abs(st2f).^2/Ts));axis([-55-4040]);gridylabel('单极性RZ功率谱密度(dB/Hz)');subplot(425)plot(t,[st3(1:length(t))]);axis([020-1.51.5]);gridylabel('双极性NRZ波形');subplot(426);plot(f,10*log10(abs(st3f).^2/Ts));axis([-55-4040]);gridylabel('双极性NRZ功率谱密度(dB/Hz)');subplot(427)plot(t,[st4(1:length(t))]);axis([020-1.51.5]);gridylabel('双极性RZ波形');subplot(428);plot(f,10*log10(abs(st4f).^2/Ts));axis([-55-4040]);gridylabel('双极性RZ功率谱密度(dB/Hz)');2文件名为digit_ber.m%数字基带接收机的性能digit_ber.mclearall;closeall;EbN0dB=0:0.5:10;N0=10.^(-EbN0dB/10);sigma=sqrt(N0/2);Pb=0.5*erfc(sqrt(1./N0));%理论计算的误码率forn=1:length(EbN0dB)a=sign(randn(1,100000));rk=a+sigma(n)*randn(1,100000);dec_a=sign(rk);ber(n)=sum(abs(a-dec_a)/2)/length(a);endsemilogy(EbN0dB,Pb);hold;semilogy(EbN0dB,ber,'rd-');legend('理论值','仿真结果');xlabel('Eb/N0(dB)');ylabel('Pb');3文件名为sigexpand.mfunction[out]=sigexpand(d,M)%将输入的序列扩展成间隔为N-1个0的序列N=length(d);out=zeros(M,N);out(1,:)=d;out=reshape(out,1,M*N);4文件名为T2F.mfunction[f,sf]=T2F(t,st)%ThisisafunctionusingtheFFTfunciontocalculateasignal'sFourier%Translation%inputisthetimeandthesignalvertors,thelengthoftimemustgreater%than2%Outputisthefrequencyandthesignalspectrumdt=t(2)-t(1);T=t(end);df=1/T;N=length(st);f=-N/2*df:df:N/2*df-df;sf=fft(st);sf=T/N*fftshift(sf);