[Scilab-users] Fwd: Help modeling ODE system

Farid Afandiyev faridafandiyev at gmail.com
Sun Sep 14 16:54:52 CEST 2014


Thanks Mehran! This is exactly what I want!

Kind regards,

Farid.

On Sun, Sep 14, 2014 at 4:04 PM, A Khorshidi <akhorshidi at live.com> wrote:

> Farid Afandiyev wrote
> > It looks like this
> > dV1/dt = 0.01V1 - 0.01V2
> > dV2/dt = -0.01V1 + 0.01V2
> > V1(0) = 10000
> > V2(0) = 5000
> >
> > I want to plot V1 and V2 against time t=[0:10]
>
> Hi;
>
> You can use the scheme below to solve system of ODEs in Scilab:
> //
> function xdot = modelName(t,x)
>     xdot = f(t,x) // where xdot and x are vectors
> endfunction
>
> x0 = [x1(0) x2(0)... xn(0)]' // a vector of the initial conditions
> t0 = initialTime // a scalar: initial time
> tf = finalTime // a scalar: final time
> t = linspace(t0, tf)// a vector: the times that you want a solution for
>
> x = ode(x0,t0,t,modelName);
>
> plot(t', [x(1,:); x(2,:); ... x($,:)]')
> //
>
> And to really answer your question:
>
> function Vdot=model(t, V)
>     Vdot(1) = 0.01*V(1) - 0.01*V(2)
>     Vdot(2) = -0.01*V(1) + 0.01*V(2)
> endfunction
> V0=[10000 5000]';
> t0=0;
> t=0:0.1:10;
> V = ode(V0,t0,t,model);
> plot(t', [V(1,:); V(2,:)]')
>
> HTH
> Mehran
> _
>
>
>
>
> --
> View this message in context:
> http://mailinglists.scilab.org/Scilab-users-Fwd-Help-modeling-ODE-system-tp4031148p4031151.html
> Sent from the Scilab users - Mailing Lists Archives mailing list archive
> at Nabble.com.
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20140914/76a942d5/attachment.htm>


More information about the users mailing list