help-octave
[Top][All Lists]
Advanced

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

RE: LSODE Question - External Inputs?


From: Allen.Windhorn
Subject: RE: LSODE Question - External Inputs?
Date: Thu, 23 Feb 2012 10:19:06 -0600

Damian,

-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of damian.harty

> I'm trying to use Octave to reproduce calculations I've done
> elsewhere, with a global objective of moving away from Excel and
> Simulink over time.
> ...
> Now, what I want to is to introduce an excitation function at the
> base. I have some function u(t) that is known in advance. I can
> presume that its derivative, udot(t) will also be known in advance
> (or at least calculated).
>
> But what I can't really see is how to pass these two vectors into
> the function "xdot". (Actually it ought to be clear I can't work out
> how to pass anything into xdot without lsode having a sulk. I want
> to declare m, k and c externally and have them picked up inside xdot
> but can't work out how to do that, either)

A trick I have used is to increase the size of the X vector and pass
them in as "stealth" members -- their derivatives would be set to zero
so they wouldn't change.  Another way I have used is global variables
(yuck).  It may also be possible to use a nested function for xdot, so
that it shares the same namespace as the calling function.

I suspect there is a more elegant way, so will be watching the
responses.

> If I write my equations out on paper they become

> xdot_1(t) = x_2(t)
> xdot_2(t) = -k/m*( x_1(t) - u(t) ) - c/m*( x_2(t) - udot(t) )

> but I'm clearly missing something in terms of how to formulate it
> inside the xdot function in Octave to subtract the right value of u
> at any moment in time as xdot contains no sense of time as far as I
> can see.

The calling function is explicitly passing t, so you have access to
that within the xdot function.  If your u(t) is defined by a table,
you will have to define a function that interpolates the table, since
the timesteps are variable.

Regards,
Allen
-- 
Allen Windhorn, P.E. (MN), CEng  (507) 345-2782
Kato Engineering
P.O. Box 8447, N. Mankato, MN  56002
address@hidden



reply via email to

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