help-octave
[Top][All Lists]
Advanced

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

Problem defining global vars


From: Christian Renz
Subject: Problem defining global vars
Date: Mon, 28 Jun 2004 17:03:31 -0500

I'm quite new to octave, so forgive me if this is an overly simple question. But I wasn't able to find the answer in the wiki or in the manual.

When I run the following script, octave complains that a and b are undefined. Once I move the definitions inside the function f, everything works fine, however. Is there a way I can define a and b so they are recognized by f (when used via lsode)?

----------8<----------8<----------
global a = [ -1, 0.5 ; 1, -1];
global b = [ 0.5 ; 0.5 ];

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

x0 = [ 5; 0 ];
t = linspace(0, 10, 100)';
x = lsode("f", x0, t);

plot (t, x);
----------8<----------8<----------

Thanks for your help!

Greetings,
   Christian Renz

--
address@hidden - http://www.web42.com/crenz/ - http://www.web42.com/



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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