[scilab-Users] Solving lorenz equations by runge kutta and euler method

Jerome PICARD jerome.picard at scilab.org
Tue Mar 16 09:27:43 CET 2010


Hello,

If you want to obtain X, Y and Z as a vector, you just have to replace X 
by X(i) in the loop.
But a faster solution to create the grid without the loop and saving 
every line in a file in is to use the Scilab function meshgrid.

Best regards

Jérôme


Jean-Baptiste Bordellier wrote:
> Hello.
> I'm trying to make a comparison between diverse methods for solving 
> differential equation.
> I cannot use ode or any related command since the aim is to get a 
> proper code which will help me compare the efficiency of the methods.
> I open a discussion  on usenet. 
> http://groups.google.fr/group/comp.soft-sys.math.scilab/browse_thread/thread/875cb3e8e2e80c09?hl=fr#
> So war i got.
>
> // Set the value of h to chose a step size.
> h=0.001;
> //set the value of imax to chose the number of iteration.
> imax=200;
>
> //Set the values of Xo, Yo, and Zo which are inital condition
> Xo=10;
> Yo=10;
> Zo=10
> Unit=[Xo;Yo;Zo];
> //Set values of sigma=s, r and beta=b
> s=10;
> r=28;
> b=2.67;
>
> fdx=mopen('C:\lorenz attractor\Lorenz attractorx.txt','wb')
> for i=1:imax,
>   X=Xo+(-s*Xo+s*Yo)*h;
>   Y=Yo+(-Xo*Zo+r*Xo-Yo)*h;
>   Z=Zo+(Xo*Yo-b*Zo)*h;
>   Xo=X;
>   Yo=Y;
>   Zo=Z;
>   save(fdx,X,Y,Z),  // save data in file
>  end
>   mclose(fdx)
>
>   fdx=mopen('C:\lorenz attractor\Lorenz attractorx.txt','rb')
>
>   for k=1:imax, load(fdx,'X','Y','Z');X;end  // read data from file
>   for k=1:imax, load(fdx,'X','Y','Z');Y;end
>   for k=1:imax, load(fdx,'X','Y','Z');Z;end
>
> mclose(fdx);
>
> The problem is that I cannot obtain the values of X, Y and Z as a vector.
> I need that in order to plot 2d and 3d graphs of the lorenz equation.
>
> If anybody as any clue please let me know.
> Kind regards from France.
>
>


-- 
Jérôme Picard
Ingénieur de développement
-------------------------
Consortium Scilab
Digiteo
Domaine de Voluceau
Rocquencourt - B.P. 105 
78153 Le Chesnay Cedex
Tél. : 01.39.63.55.91




More information about the users mailing list