[Scilab-users] Fwd: Help modeling ODE system

Stéphane Mottelet stephane.mottelet at utc.fr
Mon Sep 15 14:03:44 CEST 2014


Hello,

Why use a cannon to kill a fly ? Maybe this would be easier like this :

function dvdt=f(t,v)
     dvdt=[0.01 -0.01;-0.01 0.01]*v;
endfunction

t=0:0.1:10;
v=ode([10000;5000],0,t,f);
plot(t,v)

S.

Le 15/09/2014 13:05, Berns Buenaobra a écrit :
> You could simulate those in XCOS like an analog computation using
> Differentiators and its inverse for the solution also multipliers by the
> way.
>
> Berns B.
>
> On Sun, Sep 14, 2014 at 10:54 PM, Farid Afandiyev <faridafandiyev at gmail.com>
> wrote:
>
>> 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
>>>
>>
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> http://lists.scilab.org/mailman/listinfo/users
>>
>>
>
>
>
> _______________________________________________
> 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/20140915/e7ba2c10/attachment.htm>


More information about the users mailing list