help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Non homogeneous differential equations


From: François Poulain
Subject: Re: Non homogeneous differential equations
Date: Tue, 22 May 2007 20:49:47 +0200

Thank you for your help, but it doesn't work in octave : you can see the
computation below. I already tried some things like that, and I didn't
find any way to solve this problem ...

octave:1> function xdot = f (x, t, uf, tauf)
>   persistent a = 1
>   persistent b = 1
>   u = uf (t);
>   xdot = [-a*x(4)*sin(x(3))+u(1);
>           -a*x(4)*cos(x(3))+u(2);
>           -x(4)+u(3);
>           b*(x(1)*sin(x(3))+x(2)*cos(x(3)))-tauf(t)];
> endfunction
octave:2>  t = linspace (0, 1, 101);
octave:3>  x = lsode (@ (x, t) f (x, t, @ (t) t.^((0:2)'), @sin), zeros
(4, 1),t);
error: lsode: first arg should be a string or 2-element string array
error: evaluating assignment expression near line 3, column 4
octave:3> 

Le mardi 22 mai 2007 à 10:09 +1000, Geordie McBain a écrit :
> Hi.  Thanks for the explanation of the forcing.  You can do this in GNU
> Octave with lsode.  Create the function m-file f.m:
> 
> %<---
> function xdot = f (x, t, uf, tauf)
>   persistent a = 1
>   persistent b = 1
>   u = uf (t);
>   xdot = [-a*x(4)*sin(x(3))+u(1);
>         -a*x(4)*cos(x(3))+u(2);
>         -x(4)+u(3);
>         b*(x(1)*sin(x(3))+x(2)*cos(x(3)))-tauf(t)];
> endfunction
> %<---
> 
> And then invoke lsode like:
> 
> %<---
>  t = linspace (0, 1, 101);
>  x = lsode (@ (x, t) f (x, t, @ (t) t.^((0:2)'), @sin), zeros (4, 1),
> t);
> %<---
> 
> which will give you x as a 101 x 4 array.
> 
> Hope that solves the problem.
> 
> Geordie McBain
> 
> 
> Send instant messages to your online friends http://au.messenger.yahoo.com 
> 
-- 
François Poulain <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]