MATLAB版本的
clc;
clear all;
close all;
SNR=10;
time=1:0.01:100;
triger=zeros(1,length(time));
for i=25:50:length(time)
triger(i)=1;
end
y=sin(2*pi*time);
y=awgn(y,SNR);;
for i=1:1:length(y);
subplot(311);
stairs(triger(i:i+300));
axis([0 300 -1.1 1.1]);
subplot(312);
plot(y(i:i+300));
rectangle('Position',[100,-1,100,2],'edgecolor','r')
axis([0 300 -1.1 1.1]);
pause(0.001);
if triger(i+150)==1
pause(0.5);
subplot(313);
plot(y(i+100:i+200));
axis([0 100 -1.1 1.1]);
hold on;
end
end