help-octave
[Top][All Lists]
Advanced

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

Integrating functions with with constant arguments


From: John Dalton
Subject: Integrating functions with with constant arguments
Date: Tue, 15 Aug 2006 15:29:48 +1000

QUESTION 1:

I'm trying to run the following function under octave:

function z = test_handle(t)
   z   = quad(@(x) pow2(x, t), 0.5, 1);
end

It is an integration with a constant argument in the integrand function.
It works in Matlab, but octave 2.1.73 fails with the
following error. 

error: `t' undefined

According to this post: 
http://velveeta.che.wisc.edu/octave/lists/archive//octave-maintainers.2002/msg00110.html
it should work.  I've also tried making 't' global ("global t") and
also tried using a global intermediate variable between the argument t
and its use as a  parameter to pow2.  If pow2 is replaced with a user
defined function (say fun2) the code fails saying "fun2" is not
defined.  It's as if the evaluation of quad's argument function is
not seeing the parent's environment.

QUESTION 2:

As an aside, I also did the following test:

octave:5> global a=3;is_global('a')
ans = 0

I would have though the answer should be '1'.


Sorry if these are FAQs.  I have spent a day looking for an
answer but have not found one (apart from the email above).
Any help will be appreciated very much. (Thanks in advance.)

Regards
John Dalton




reply via email to

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