在Scilab中创建动画 [英] Creating Animation in Scilab

查看:160
本文介绍了在Scilab中创建动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用以下代码使用x和y坐标绘制点。

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?

推荐答案

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

这篇关于在Scilab中创建动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆