[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help need for Differential algebraic equations
From: |
Carlo de Falco |
Subject: |
Re: Help need for Differential algebraic equations |
Date: |
Thu, 9 Oct 2008 18:52:38 +0100 |
On 09/ott/08, at 18:09, genehacker wrote:
**********code ********
function res = f(x,xdot,t);
res = zeros(3,1);
k12=0.1;
k23=0.7;
xdot(1) = -k12*x(1);
xdot(2) = k12*x(1) - k23*x(2);
xdot(3) = k23*x(2);
endfunction;
as it stands this function does not make much sense:
whatever its input is it will always return [0 0 0].'
to check, try for example running the following command multiple times:
f (rand(3,1), rand(3,1), rand(1))
as xdot is not an output of the function, whatever value
you assign to it will be lost when the function returns.
I suggest you read the manual chapter on defining functions:
http://www.gnu.org/software/octave/doc/interpreter/Functions-and-Scripts.html#Functions-and-Scripts
to understand how input and output parameters are handled
x0 = [100,0,0];
xdot0 =[-10,10,10];
t = linspace(0,50,50);
[x,xdot] = dassl("f",x0,xdot0,t);
the first sentence in the documentation of dassl reads:
"-- Loadable Function: [X, XDOT, ISTATE, MSG] = dassl (FCN, X_0,
XDOT_0, T, T_CRIT)
Solve the set of differential-algebraic equations
0 = f (x, xdot, t)"
so, put in mathematical terms, the problem you are trying to solve
with this statement reads:
find x(t) such that f(x,x',t) = 0 for 0<= t <= 50
as with your definition f(x,x',t) = 0 is verified for any value of x,
x' and t,
the problem is not well posed as ANY function x(t) is a solution.
c.