[Scilab-users] How to get matrix output from ODE ?

classic Classic list List threaded Threaded
3 messages Options
marko marko
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] How to get matrix output from ODE ?

Hello - using scilab 6.0.2 on windows 7 pro;
I'm pretty much a newbie here, but somewhat familiar with differential
equations.
However, I cannot find a way to get a matrix (NOT a VECTOR!) output from
the scilab 'ode' function. No matter what, all it gives is a row vector.
Example code (nonlinear Rossler equations):

  function [ydot]=rdv(t,y)
      ydot(1) = -(y(2) + y(3))
      ydot(2) = y(1) + 0.2*y(2)
      ydot(3) = 0.2 + y(3)*(y(1) - 5.7)
endfunction
t=0:0.05:50;
t0=0;y0=[-1.0,0.0,0.0];
y=ode(y0,t0,t,list(rdv,a,b,c));
param3d(y(1),y(2),y(3))

... makes 'plot', an empty 3-d box. This makes sense, because scilab
says the 'y' variable is a simple '1x3003' row vector.
No matter how I ask for the LHS output, (examples: [y],
[y1,y2,y3,]...[y(1),y(2),y(3)...],) I get only errors or empty plot.
'Help' claims 'y' should be a vector "or matrix", but the "matrix" never
shows up at all. Scilab 'help' has no examples of simple matrix systems
of all 1st order DE's, and I cannot find any such examples online.

Some older references (including books) suggest indexing like '[y(1,:),
y(2,:), y(3,:)]'. This just gives 'indexing error' in 6.0.2.

This is easily solved with fortran using the ancient Netlib 'RKF45'
package. THEN I can plot the parametric solution by reading in to scilab.

  But I cannot quite understand how to get any useful solution from
scilab. Maybe there is a way to 'partition' the simple row vector output
into what SHOULD BE a 3 x 1001 matrix (or 1001 x 3, whatever).

What am I doing wrong? Thanks for any help here.

jrc

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: How to get matrix output from ODE ?

Hello,

Le 22/04/2019 à 14:48, Richard a écrit :
Hello - using scilab 6.0.2 on windows 7 pro;
I'm pretty much a newbie here, but somewhat familiar with differential equations.
However, I cannot find a way to get a matrix (NOT a VECTOR!) output from the scilab 'ode' function. No matter what, all it gives is a row vector.
Example code (nonlinear Rossler equations):

 function [ydot]=rdv(t,y)
     ydot(1) = -(y(2) + y(3))
     ydot(2) = y(1) + 0.2*y(2)
     ydot(3) = 0.2 + y(3)*(y(1) - 5.7)
endfunction
t=0:0.05:50;
t0=0;y0=[-1.0,0.0,0.0];
y=ode(y0,t0,t,list(rdv,a,b,c));
param3d(y(1),y(2),y(3))

y0 = [-1.0,0.0,0.0]';
y = ode(y0,t0,t,rdv);
param3d(y(1,:),y(2,:),y(3,:))

works:


But the fact that y and t must be of "orthogonal shapes" is not clearly indicated
or highlighted in the ode() help page. This clearly misses.
There are some (rather unclear) explanation for y being even a matrix !
but for simpler multivariable cases, nothing.
We should improve the page.
Anyway, writting param3d(y(1),y(2),y(3))  plots only one point. HTH Samuel
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
marko marko
Reply | Threaded
Open this post in threaded view
|

Re: How to get matrix output from ODE ?

In reply to this post by marko
Thank you Samuel! Very helpful explanation!

I did discover also that if y0 were specified as [-1.0;0.0;0.0] (orthogonal
?) I then get a matrix output indeed. Playing around found also that (then)
plotting with (y(1,:),y(2,:),y(3,:)) does work after all.

But your explanation *really* filled in the blanks for me. Many thanks!

marko



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users