help-octave
[Top][All Lists]
Advanced

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

Re: DAE solver with additional parameters


From: c.
Subject: Re: DAE solver with additional parameters
Date: Wed, 2 Jul 2014 09:53:08 +0200

On 2 Jul 2014, at 07:00, lordgogi <address@hidden> wrote:

> 
> Hi,
> 
> I use Octave to simulate thermodynamic system. I have a set of DAE and solve
> them with
> dassl function. However I would like to pass additional parameters. Can
> anyone help me with that?

this is the recommended approach using an anonymous function:

a = 1; b = 1; c = 1;

function res = f (x, xdot, t, a, b, c)
  global a b c
  res = xdot + (a * b * c) * x;
endfunction

x = daspk (@(x, xdot, t) f(x, xdot, t, a, b, c), 
           1, -1, [0, 10]); 

> I also tried to use global variables but it does
> not work either.

what you mean by "it does not work"?
although it is not the recommended approach, 
it should definitely work for your problem.

try this:

global a b c
a = 1;
b = 1;
c = 1;

function res = f (x, xdot, t)
  global a b c
  res = xdot + (a * b * c) * x;
endfunction

x = daspk (@f, 1, -1, [0, 10]); 


> Thank you

c.


reply via email to

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