[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
LSODE Question - External Inputs?
From: |
damian.harty |
Subject: |
LSODE Question - External Inputs? |
Date: |
Thu, 23 Feb 2012 07:42:50 -0800 (PST) |
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.
- LSODE Question - External Inputs?,
damian.harty <=
- Re: LSODE Question - External Inputs?, Juan Pablo Carbajal, 2012/02/23
- Re: LSODE Question - External Inputs?, Olaf Till, 2012/02/23
- Re: LSODE Question - External Inputs?, damian.harty, 2012/02/23
- Re: LSODE Question - External Inputs?, Juan Pablo Carbajal, 2012/02/23
- Re: LSODE Question - External Inputs?, damian.harty, 2012/02/24
- Re: LSODE Question - External Inputs?, Olaf Till, 2012/02/24
- Re: LSODE Question - External Inputs?, damian.harty, 2012/02/24
- Re: LSODE Question - External Inputs?, Juan Pablo Carbajal, 2012/02/24
- Re: LSODE Question - External Inputs?, damian.harty, 2012/02/24
- Re: LSODE Question - External Inputs?, Olaf Till, 2012/02/24