help-octave
[Top][All Lists]
Advanced

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

Re: LSODE Question - External Inputs?


From: Olaf Till
Subject: Re: LSODE Question - External Inputs?
Date: Thu, 23 Feb 2012 17:06:18 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

On Thu, Feb 23, 2012 at 07:42:50AM -0800, damian.harty wrote:
> ...
> 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)
> ...

This is an FAQ. Maybe there is already something in the manual for this, if
not, it should be included ...

To pass additional arguments for a passed function (for example with
lsode) you can use anonymous functions, like that:

# a and b are arguments with additional information
a = linspace (0, 1, 1001);
b.x = .1;
b.y = .2;

X = lsode (@ (x, t) fdot (x, t, a, b), x0, t);

If you are not familiar with anonymous functions, you should refer to the
manual first.

In the example, your user function would have to be something like

function ret = fdot (X, T, A, B)
...

A and B will be set to a and b when the function is called by lsode.

Olaf

-- 
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

Attachment: signature.asc
Description: Digital signature


reply via email to

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