先分享一段好玩点的代码吧~串口多路波形监控和这个类似,但是比这个要复杂,这个仅仅是多路波形动态显示~串口还要加上帧头和帧尾,等我最近研究一段时间,再给大家分享怎么用串口将多路波形返回~
hold on
h1 = plot(0,'.b','MarkerSize',5);
h2 = plot(0,'.g','MarkerSize',5);
h3 = plot(0,'.r','MarkerSize',5);
h4 = plot(0,'.c','MarkerSize',5);
h5 = plot(0,'.m','MarkerSize',5);
h6 = plot(0,'.y','MarkerSize',5);
h7 = plot(0,'.k','MarkerSize',5);
H = [h1;h2;h3;h4;h5;h6;h7];
%set(h,'erasemode', 'none');
x = 1:0.01:3*pi;
y1 = cos(x);
y2 = sin(x);
y3 = sin(x+0.5);
y4 = sin(x+1);
y5 = sin(x+1.5);
y6 = sin(x+2);
y7 = sin(x+2.5);
Y = [y1;y2;y3;y4;y5;y6;y7];
for i = 1:600
for j = 1:7
set(H(j),'xdata',x(1:i),'ydata',Y(j,1:i));
end
axis([x(i)-2 x(i)+0.3 -1 1])
drawnow
end