[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Minimising anonymous/inline function
From: |
J Heeris |
Subject: |
Minimising anonymous/inline function |
Date: |
Wed, 18 Mar 2009 20:02:57 -0700 (PDT) |
Say I have a struct that contains a function:
item = struct('x', 1, 'y', 2, 'f', @sin);
How do I minimise item.f? I can't use the octave-forge minimize, because the
leval function in the optimisation package expects a string, but then when
it calls feval, it needs the function handle.
> minimize(params.f, 0)
error: octave_base_value::convert_to_str_internal (): wrong type argument
`function handle'
error: leval: first argument must be a string
error: leval: second argument must be a list
error: feval: the symbol `' is not valid as a function
error: evaluating assignment expression near line 153, column 8
error: evaluating for command near line 152, column 1
error: called from `nelder_mead_min' in file
`/usr/share/octave/packages/optim-1.0.3/nelder_mead_min.m'
error: evaluating if command near line 276, column 3
error: evaluating if command near line 275, column 1
error: called from `minimize' in file
`/usr/share/octave/packages/optim-1.0.3/minimize.m'
> minimize("params.f", 0)
error: feval: the symbol `params.f' is not valid as a function
error: evaluating assignment expression near line 153, column 8
error: evaluating for command near line 152, column 1
error: called from `nelder_mead_min' in file
`/usr/share/octave/packages/optim-1.0.3/nelder_mead_min.m'
error: evaluating if command near line 276, column 3
error: evaluating if command near line 275, column 1
error: called from `minimize' in file
`/usr/share/octave/packages/optim-1.0.3/minimize.m'
At the moment I'm going to go through my code, extract all the computations
and define a separate function file that can take the necessary parameters.
So I guess my real question is: is there an easier way than that?
--
View this message in context:
http://www.nabble.com/Minimising-anonymous-inline-function-tp22592786p22592786.html
Sent from the Octave - General mailing list archive at Nabble.com.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Minimising anonymous/inline function,
J Heeris <=