help-octave
[Top][All Lists]
Advanced

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

Re: simulating dynamical systems with arbitrary external inputs using ls


From: John W. Eaton
Subject: Re: simulating dynamical systems with arbitrary external inputs using lsode
Date: Fri, 22 Jun 2007 16:12:32 -0400

On 22-Jun-2007, Scott Kuntze wrote:

| Using an input function like this does indeed work -- I've used it to 
| define rectangular pulses and the like -- but it doesn't solve the 
| problem of setting u(t) to reference an arbitrary waveform that could be 
| loaded from an experimental data file.
| 
| For example, if 'waveform' is a distorted waveform with transients and 
| noise, it quickly becomes difficult to write mathematical 
| representations with if / then statements. 
| 
| The other suggestion to use polyfit on 'waveform' is an interesting one, 
| but again it will break down if 'waveform' is extremely complex (which 
| it could be).
| 
| Any other suggestions on getting lsode to use an arbitrary input vector?
| 
| I guess I'm surprised this isn't simple to do -- I'm simply trying to 
| compare a dynamic model to an experiment, and would like to use the 
| exact input I captured from the experiment as the input into the simulation.

What do you mean by "exact input"?  You have data at points.  You need
to be able to get values at any time T.  What sort of approximation do
you want for the times in between the data points?  Zero order hold? 
Linear interpolation?  Polynomial fit?  It's up to you.  I don't think
it's exceptionally hard to write code for any of these.

Would it have helped if I had written something like

  function retval = u (t)
    ## This is a zero-order hold function.  TVALS are the switching
    ## times, UVALS are the values of U up until the corresponing
    ## element of tval.
    tvals = [5, 10, 15, Inf];
    uvals = [1, -1, 1, 0];
    idx = find (t < tvals, 1, "first");
    retval = uvals (idx);
  endfunction

instead of using if/elseif/else/endif?

jwe


reply via email to

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