[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
passing functions handles to functions
From: |
Christophe Prud'homme |
Subject: |
passing functions handles to functions |
Date: |
Wed, 8 Mar 2006 16:26:31 +0100 |
User-agent: |
KMail/1.9.1 |
Hi again,
In octave, you can define function using 'function' and 'inline'
however functions like 'fzero' accepts only functions defined by
'function' (and not inline)
for example
---------------------------
function y = fun(x)
y = x.^2 - 1 + exp(x);
end
fzero("fun", 1)
---------------------------
Ok
but
--------------------------
f=inline('x.^2 - 1 + exp(x)')
f =
f(x) = x.^2 - 1 + exp(x)
octave:2> argnames(f)
ans =
{
[1,1] = x
}
octave:3> fzero('f',1)
error: feval: the symbol `f' is not valid as a function
error: evaluating assignment expression near line 358, column 5
error: evaluating if command near line 208, column 2
error: called from `fzero' in file
`/usr/share/octave/site/m/octave-forge/optim/fzero.m'
-------------------------
in matlab inline, and strings can be used.
is there a general rule in octave regarding passing function handles ?
like you can pass only functions handles of functions defined using
'function' ?
or does it depend on the function using the function handle like fzero ?
or am I missing something ?
Best regards
C.
--
Christophe Prud'homme
Office MA B2 534
CMCS-IACS EPFL
CH-1015 Lausanne, Switzerland
Tel: +41 (0)21 693 25 47
Fax: +41 (0)21 693 43 03
-------------------------------------------------------------
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
-------------------------------------------------------------
- passing functions handles to functions,
Christophe Prud'homme <=