%%导入卡农.mps,data是一堆数据,然后显示
clear
clc
colordef black
data=audioread('卡农.mp3');
data =data(200919:753400,:);
a1 = animatedline('Color',[0 .7 .7]);
a2 = animatedline('Color',[0 .5 .5]);
data_size = size(data(:,1));
data_max = max(data(:,1));
data_min = min(data(:,1));
%axis([1 data_size(1) -1 1 ])
x = linspace(0,(data_size(1)-1),data_size(1));
y1 = data(:,1);
y1 = y1';
y2 = data(:,2);
y2 = y2';
%m = 0;
k = 1;
% while (k>10*m)&&(k<=10*(m+1))&&(k<data_size(1))
while (k>0)&&(k<data_size(1))
axis([0 10 -0.02 0.02 ])
% if k ==10*(m+1)
if k>10
axis([k-9 k-1 -0.02 0.02 ])
text(x(k),y1(k),'o','color','g');
end
%m = m+1;
% end
addpoints(a1,x(k),y1(k));
disp('x(k)')
disp(x(k))
disp('y1(k)')
disp(y1(k))
k = k+1;
pause(1)
drawnow
end
效果如下图所示,但是,因为text标注的点,会已知留着标注,所以结果差一点,不知道怎么纠正,希望看过的朋友帮忙看一下