[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: usage of inline and fminbnd
From: |
etienne |
Subject: |
Re: usage of inline and fminbnd |
Date: |
Tue, 13 Feb 2007 21:56:19 -0800 (PST) |
User-agent: |
SquirrelMail/1.4.4 |
Hi Chris,
fminbnd works for me, as long as I pass something (e.g. an empty vector)
for the OPTIONS arg, to separate the first argument ("x") from the fixed
P1 argument ("b", in your case):
octave:25> help fminbnd
-- Function File: [X] = fminbnd(F,LB,UB,[OPTIONS],P1,P2, ...)
Find the minimum of a scalar function with the Golden Search
method.
*Inputs*
F
A string contining the name of the function to minimiz
LB
Value to use as an initial lower bound on X.
UB
Value to use as an initial upper bound on X.
OPTIONS
Vector with control parameters (For compatibily with MATLAB,
not used here)
P1,P2, ...
Optional parameter for function F
octave:26> function y = my_example_func (x,b), if nargin<2, b = 2.34;
endif; y = - cos (x-b) + (x-b)^2; endfunction
octave:27> x0 = fminbnd ("my_example_func",0,10) x0 = 2.3400
octave:28> x0 = fminbnd ("my_example_func",0,10,[],1.23)
x0 = 1.2300
Hth,
Etienne
On Tue, February 13, 2007 12:29 pm, Chris Zarowski said:
> Hello.
>
> I cannot figure out how to use fminbnd (Golden section
> search minimizer).
>
> The problem is that I cannot pass a constant
> parameter.
>
> In the attached script I want to minimize f(x,b)
> w.r.t x on interval [0,fp], but I need to vary f according
> to constant b.
>
> Thanks in advance,
> Chris Z_______________________________________________
> Help-octave mailing list
> address@hidden
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>
--
http://www.isr.ist.utl.pt/~etienne