clearall;closeall;fs=8e5;%抽样频率fm=20e3;%基带频率n=2*(6*fs/fm);final=(1/fs)*(n-1);fc=2e5;%载波频率t=0:1/fs:(final);Fn=fs/2;%耐奎斯特频率%用正弦波产生方波%==========================================twopi_fc_t=2*pi*fm*t;A=1;phi=0;x=A*cos(twopi_fc_t+phi);%方波am=1;x(x>0)=am;x(x<0)=-1;figure(1)subplot(321);plot(t,x);axis([02e-4-22]);title('基带信号');gridoncar=sin(2*pi*fc*t);%载波ask=x.*car;%载波调制subplot(322);plot(t,ask);axis([0200e-6-22]);title('PSK信号');gridon;%=====================================================vn=0.1;noise=vn*(randn(size(t)));%产生乐音subplot(323);plot(t,noise);gridon;title('乐音信号');axis([0.2e-3-11]);askn=(ask+noise);%调制后加噪subplot(324);plot(t,askn);axis([0200e-6-22]);title('加噪后信号');gridon;%带通滤波%======================================================================fBW=40e3;f=[0:3e3:4e5];w=2*pi*f/fs;z=exp(w*j);BW=2*pi*fBW/fs;a=.8547;%BW=2(1-a)/sqrt(a)p=(j^2*a^2);gain=.135;Hz=gain*(z+1).*(z-1)./(z.^2-(p));subplot(325);plot(f,abs(Hz));title('带通滤波器');gridon;Hz(Hz==0)=10^(8);%avoidlog(0)subplot(326);plot(f,20*log10(abs(Hz)));gridon;title('Receiver-3dBFilterResponse');axis([1e53e5-31]);%滤波器系数a=[100.7305];%[10p]b=[0.1350-0.135];%gain*[10-1]faskn=filter(b,a,askn);figure(2)subplot(321);plot(t,faskn);axis([0100e-6-22]);title('通过带通滤波后输出');gridon;cm=faskn.*car;%解调subplot(322);plot(t,cm);axis([0100e-6-22]);gridon;title('通过相乘器后输出');%低通滤波器%==================================================================p=0.72;gain1=0.14;%gain=(1-p)/2Hz1=gain1*(z+1)./(z-(p));subplot(323);Hz1(Hz1==0)=10^(-8);%avoidlog(0)plot(f,20*log10(abs(Hz1)));gridon;title('LPF-3dBresponse');axis([05e4-31]);%滤波器系数a1=[1-0.72];%(z-(p))b1=[0.140.14];%gain*[11]so=filter(b1,a1,cm);so=so*10;%addgainso=so-mean(so);%removesDCcomponentsubplot(324);
1