help-octave
[Top][All Lists]
Advanced

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

Re: Non homogeneous differential equations


From: Geordie McBain
Subject: Re: Non homogeneous differential equations
Date: Tue, 22 May 2007 10:09:26 +1000

On Mon, 2007-05-21 at 20:47 +0200, François Poulain wrote:
> I know the "lsode" function, but I didn't find how work with it in the
> case of non homogeneous equations (witch mean that I have some input
> time varying signals in my equations).
> 
> I am working about non linear control theory, and I works with models
> like the following (in LaTeX format) :
> 
> \begin{align}
> \dot x_1 &= - a x_4 sin x_3 + u1(t)                   \\
> \dot x_2 &= - a x_4 cos x_3 + u2(t)                   \\
> \dot x_3 &= - x_4 + u3(t)                             \\
> \dot x_4 &= b ( x_1 sin x_3 + x_2 cos x_3) - \tau(t)
> \end{align}
> with measured output $y = (x_1,  x_2)$, parameters  $a,b>0$,
> inputs $(u1, u2, u3)$.
> 
> Under matlab, when I create any function dot_x = f(x,t,u1,u2,...), I can
> integrate it, because matlab use the only 2 firsts arguments to
> integrate, but the others argument are used to give input signals (and
> we need to interpolate them at the current time t in the function).
> 
> I didn't find any way of doing it under GNU/Octave, and it's a problem
> for me, because it's the only one privative software that I am using
> currently.

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 


reply via email to

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