我可以使用以下代码使用x和y坐标绘制点。
figure(1);
plot(x(1),y(1),'o');
h_compound = gce();
h_compound.children.mark_size = 20;
h_compound.children.mark_background = 2;
h_axes = gca();
h_axes.data_bounds = [0,0;100,100];
我的程序包含一个循环,用于不断刷新坐标值。每次执行循环时,该点都绘制在同一图形中,以使新点与旧点重叠。当绘制新点以便生成类似动画的序列时,如何使旧点消失?
答案 0 :(得分:1)
scf(1);clf;
x=linspace(0,10,100);
y=sin(x);
plot(x(1),y(1),"o")
h_compound = gce();
h_point=h_compound.children
h_point.mark_size = 20;
h_point.mark_background = 2;
h_axes = gca();
h_axes.data_bounds = [0,-1;10,1];
realtimeinit(0.1);
for i=1:100
realtime(i);//wait 0.1 second before drawing the new position
h_point.data=[x(i),y(i)];
end