dipakn
dipakn

Reputation: 11

Animations in SciLab

I want to plot the trajectory of a simple spring mass system using SciLab. I have successfully managed to plot a graph of x vs t. Now I want to make a gif of the trajectory of the body with respect to time (something like this https://www.youtube.com/watch?v=kAl4XATyke4). How am I supposed to go about it? Attached is my progress till now.

//Input the spring constant k, mass m. and the initial values of x and x dot. The code will plot both x (in red) and x dot (in green)

function sol = spingmass(k,m,x_initial,xdot_initial,time)
osqr = k/m;

function dx = f(t,x)
    dx(1)=x(2);
    dx(2)=-1*osqr*x(1);
endfunction

t = 0:0.1:10;
sol = ode([x_initial;xdot_initial],time,t,f);
clf;
plot(t,sol(1,:),'r');
plot(t,sol(2,:),'g');
//disp(sol);

endfunction

Upvotes: 1

Views: 719

Answers (1)

S. Gougeon
S. Gougeon

Reputation: 911

You will be able to build an animated GIF with a series of Scilab snapshots of a graphical figure thanks to the animaGIF toolbox available @ https://atoms.scilab.org/toolboxes/animaGIF

It is a standalone toolbox. No dependency like imageMagick or other GIMP is required.

The single animaGIF() function of the toolbox is extensively documented. The documentation includes some animated GIF figures, moving in the Scilab help browser. Enjoy!

Upvotes: 0

Related Questions