%clf;
t0=2; %定义变量区终止值
ts=0.01;
t=-t0+0.0001:ts:t0; %定义变量区间
fc=10; %给出相干载波的频率
A=1; %定义输入信号幅度
fa=1; %定义调制信号频率
mt=A*cos(2*pi*fa.*t); %输入调制信号表达式
xzb=2;
snr=10.^(xzb/10);
[h,l]=size(mt); %求调制信号的维数
fangcha=A*A./(2*snr); %由信躁比求方差
nit=sqrt(fangcha).*randn(h,1); %产生小信噪比高斯白躁声pmt=mt.*cos(2*pi*fc.*t); %输出调制信号表达式
snit=mt+nit; %输出已调信号波形
psmt=mt.*cos(2*pi*fc.*t); %输出调制信号表达式
pnit=nit.*cos(2*pi*fc.*t); %输出调制信号表达式
psnt=psmt+pnit;
jic=psnt.*cos(2*pi*fc.*t); %调制信号乘以相干载波
ht=(2*pi*fc.*sin(2*pi*fc.*t)./(2*pi*fc.*t))./pi; %低通滤波器的时域表达式
htw=abs(fft(ht)); %低通滤波器的频域表达式
jt=conv(ht,jic); %解调信号的时域表达式
subplot(3,3,1); %划分画图区间
plot(t,mt,'b'); %画出输入信号波形
title('输入信号波形');
xlabel('ZI t');
ylabel('ZI mt');
subplot(3,3,2);
plot(t,nit,'g');
title('输入噪声波形');
xlabel('ZI t');
ylabel('ZI mt');
subplot(3,3,2);
plot(t,nit,'g');
title('输入噪声波形');
xlabel('ZI t');
ylabel('ZI nit');
subplot(3,3,3);
plot(1:length(snit), snit,'r'); %length用于天度匹配
title('输入信号与噪声叠加波形');
xlabel('ZI t');
ylabel('ZI snit');
subplot(3,3,4);
plot(t,psmt,'c');
title('输出信号波形');
xlabel('ZI t');
ylabel('ZI psnt');
subplot(3,3,5);
plot(t,pnit,'c');
title('输出噪声波形');
xlabel('ZI t');
ylabel('ZI pnit');
subplot(3,3,6);
title('输出信号与输出噪声叠加波形');
plot(t,psnt,'c');
xlabel('ZI t');
ylabel('ZI psnt' );
subplot(3,3,7);
plot(1:length(htw),htw,'c');
title('低通滤波器频域波形'); %画出低通滤波器频域波形
xlabel('ZI w’');
ylabel('ZI htw');
axis([0 60 0 150]);
subplot(3,3,8);
plot(1:length(ht),ht,'c');
title('低通滤波器频域波形');
xlabel('ZI t');
ylabel('ZI psnt');
axis([150 250 -20 25]); %给出坐标轴范围
subplot(3,3,9);
plot(1:length(jt),jt,'c');
title('输出信号与输出噪声叠加波形');
xlabel('ZI t');
ylabel('ZI jt');
axis([200 600 -50 501]);