clear all
f1=80;f2=100;%频率
N=5;%周期个数
t1=N*1/f1;t2=N*1/f2;
fs=2000; %采样频率,按照采样定理200hz即可,但为了光滑好看,因为信号时间较短,还是要多一些
t=0:1/fs:(t1+t2);%信号时间数组
y=sin(f1*2*pi*t).*(t>=0&t<=t1)+sin(f2*2*pi*(t-t1)).*(t>=t1&t<=(t1+t2));
%信号起始点都从0开始的正弦波,相位为零,最后相加。
plot(t,y);
xlabel('时间/S'),ylabel('信号y')
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/00e93901213fb80e67b0343834d12f2eb83894ff?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)