help-octave
[Top][All Lists]
Advanced

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

Supplying Jacobian to lsode


From: vHF
Subject: Supplying Jacobian to lsode
Date: Sat, 5 Sep 2009 12:09:02 -0700 (PDT)

Hi all,

I am relatively new to Octave and my problem is most likely rather trivial,
so I apologise in advance.
I am trying to create an .m file that would have a definition of a system of
ODEs and call the lsode solver with the Jacobian supplied. What I have now
is:

***begin script***
u = linspace(0, 72, 72*60);
init = [0; 10];

function res = f(x, u)
  res(1) = 2.0*x(2).*x(2) - 3.0*x(1); 
  res(2) = -2.0*x(2).*x(2) + 6.0*x(1); 
endfunction;

function res = jac(x, u)
  res(1) = -3.0;
res(1,2) = 2.0*x(2);
  res(2,1) = 6.0;
res(2,2) = -2.0*x(2);
endfunction;

x = lsode(["f"; "jac"], init, u);
***end script***

However, this fails with the following output:

***begin console output***
error: `x' undefined near line 5 column 16
error: evaluating binary operator `*' near line 5, column 15
error: evaluating binary operator `.*' near line 5, column 20
error: evaluating binary operator `-' near line 5, column 27
error: evaluating assignment expression near line 5, column 10
error: called from `f'
error: evaluating assignment expression near line 16, column 40
error: called from `__lsode_fcn__U__'
error: lsode: evaluation of user-supplied function failed
error: lsode: inconsistent sizes for state and derivative vectors
error: evaluating assignment expression near line 16, column 3
error: near line 16 of file `/home/marek/Desktop/octave/dimer.m'
***end console output***


What am I doing wrong?

Thanks in advance,

vHF
-- 
View this message in context: 
http://www.nabble.com/Supplying-Jacobian-to-lsode-tp25311485p25311485.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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