Creating Animation in Scilab

半世苍凉 提交于 2019-12-12 08:19:01

问题


I am able to plot a point using the x and y coordinates using the following code.

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];    

My program contains a loop which keeps on refreshing the coordinate values. Every time the loop is executed the point is plotted in the same graphic, such that the new points overlap the older ones. How do I make the old points disappear as the new points are plotted so that an animation-like sequence is generated?


回答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


来源:https://stackoverflow.com/questions/38824389/creating-animation-in-scilab

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!