clcfs=1000;fc=20;fm=1;dt=0.001N=5/dt;t=[0:N-1]*dt;snr=1;g=5*cos(2*pi*fm*t);A=5;s_am=(A+g).*cos(2*pi*fc*t);figure(1);subplot(211);plot(g);gridon;df=fs/(N-1);f=(0:N-1)*df;yg=fft(g,N);mg=abs(yg(1:N/2))*2*pi/N;subplot(212);stem(f(1:20),mg(1:20));gridon;figure(2);subplot(211);plot(s_am);holdon;plot(A+g,'r-');gridon;df=fs/(N-1);f=(0:N-1)*df;y=fft(s_am,N);m=abs(y(1:N/2))*2*pi/N;subplot(212);stem(f(1:200),m(1:200));gridon;figure(3)subplot(211);x1=awgn(s_am,snr);plot(x1);gridon;N=1500;df=fs/(N-1);f=(0:N-1)*df;y1=fft(x1,N);m1=abs(y1(1:N/2))*2*pi/N;subplot(212);stem(f(1:150),m1(1:150));gridon;y1=x1(:);figure(4)subplot(211)t1=(0:1/fs:(size(y1,1)-1)/fs)';t1=t1(:,ones(1,size(y1,2)));z1=y1.*cos(2*pi*fc*t1);[num,den]=butter(5,fc*2/fs);fori=1:size(y1,2)z1(:,i)=filtfilt(num,den,z1(:,i))*2;endplot(g);holdonxx=z1-A;plot(xx,'r')holdoff运行结果:图1原始信号及频谱图2已调信号与原始信号对比图及已调信号频谱图3加入噪声信号及频谱图4相干解调的信号与原始信号对比图