help-octave
[Top][All Lists]
Advanced

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

Re: LSODE Question - External Inputs?


From: Juan Pablo Carbajal
Subject: Re: LSODE Question - External Inputs?
Date: Thu, 23 Feb 2012 17:04:40 +0100

On Thu, Feb 23, 2012 at 4:42 PM, damian.harty
<address@hidden> wrote:
> O Learned Denizens,
>
> 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.
>
> The particular problem I'm interested in for now is vehicle ride modelling -
> my US readers will note that my spelling is British, as am I - which I have
> previously performed with some success in both Excel and Simulink. If I
> start with a nice simple system with one degree-of-freedom and linear
> characteristics, I can write
>
> function xdot = f (x, t)
>  m = 100; % kg
>  k = 10000; % N/m
>  c = 200; % Ns/m
>  xdot(1) = x(2);
>  xdot(2) =  -k/m*x(1)-c/m*x(2);
> endfunction
>
> ...and then use lsode to integrate it:
>
> endtime=4.0;
> srate=100;
> x0 = [0.1; 0];
> t = linspace (0, endtime, srate*endtime)';
> x = lsode ("xdot", x0, t);
>
> If I use non-zero initial conditions I get the faimliar damped response -
> this would be a pretty poor car with these parameters but that's neither
> here nor there.
>
> So far, so good.
>
> 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)
>
> 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.
>
> If anyone has approached this type of problem in Octave and can give me some
> pointers I would be most grateful - I'm sure it can be done but am equally
> sure I am just missing something simple. Should I be using DASSL or ode45,
> for example?
>
> Damian Harty
> Senior Research Fellow - Vehicle & System Dynamics
> Coventry University
> UK
>
> --
> View this message in context: 
> http://octave.1599824.n4.nabble.com/LSODE-Question-External-Inputs-tp4414228p4414228.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave

Hi,
I am not sure that I understand your problem.
Are you trying to actuate your system with an external input u(t)?
If so, then you just add the external input on the corresponding
variable. You can check the function core/nloscillator.m in the
package mechanics to see an example how to do that (there may be other
ways).
If you also need to add the derivative of that function you could also
do it, in principle lsode accepts any right hand-side f(x,t).

If this is not what you meant, I am failing to understand the problem.

Let me know.

-- 
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/


reply via email to

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