how to find minimum point at endpoint in matlab, please help.

clc,clear
f = @(x)((15*x)./(4*x.^2-3*x+4));
x = fminbnd(f, 0, 10);
x
y=f(x);
y
this code returns
x =
9.9999
y =
0.4011
while the real minimum is at x=0 and y=0, because of this explanation "The algorithm is based on golden section search and parabolic interpolation. Unless the left endpoint x1 is very close to the right endpoint x2, fminbnd never evaluates fun at the endpoints, so fun need only be defined for x in the interval x1 < x < x2. If the minimum actually occurs at x1 or x2, fminbnd returns an interior point at a distance of no more than 2*TolX from x1 or x2, where TolX is the termination tolerance."
how can i find the real minimum even in endpoints? please help me.

2 comentarios

If you know exactly where the end points are, would it be suffice that you just evaluate the two end points and then take the minimum of the three? After all, this is what the mathematical procedure is. Or are you having a more complicated case than shown here?
Emre
Emre el 19 de Oct. de 2011
thanks for help

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 19 de Oct. de 2011
fminbnd() is not suitable for application to functions with multiple minima. Evaluating at the endpoints would, at best, be a hack that would not help in more general cases.
You should not be using fminbnd() on that function. You should be using a global minimizer.

2 comentarios

Emre
Emre el 19 de Oct. de 2011
is there a global minimizer that i can use like fminbnd() in matlab?
There is a separate toolbox for global minimizers,
http://www.mathworks.com/help/toolbox/gads/bqe0w5v.html#bscm7nc

Iniciar sesión para comentar.

Más respuestas (2)

f = @(x)((15*x)./(4*x.^2-3*x+4));
xb = [0 10];
x1b = [xb fminbnd(f, xb(1),xb(2))];
[y,yid] = min(f(x1b));
xout = x1b(yid);
Andrei's solution is also not a global minimizer. What I propose, should the function change to something crazy like:
f = @(x) sin(2*pi*x) - x
is to use "fminsearch" with a finite number of starting "x" values. This isn't a true global minimizer either because you must chose a value "N" that will divide the range in "x" you want to search over such that the increment "dval" is not big enough to skip over a high frequency part of the signal. Here is the code:
function minimum_xy = myfminbnd(myfun, low_val, high_val, N)
% myfun is of the form "@(x) (15*x)./(4*x.^2 -3*x+4)"
% low_val is the lower value of the range to search over
% high_val is the upper value of the range to search over
% N is the number of divisions and start points to try
model = @modelfun;
min_y_estimate = 1e6;
dval = (high_val-low_val)/N;
for i = 1 : N+1
start_point = (i-1)*dval+low_val;
x_estimate = fminsearch(model, start_point);
if myfun(x_estimate) < min_y_estimate
min_y_estimate = myfun(x_estimate);
minimum_xy = [x_estimate, min_y_estimate];
end
end
function sse = modelfun(params)
try_x = params(1);
epsilon = 0;
if try_x > high_val || try_x < low_val
epsilon = 1e9;
end
sse = myfun(try_x) + epsilon;
return
end
return
end
An example:
myfminbnd(@(x) sin(2*pi*x)-x, 0, 10, 20)
ans =
9.7755 -10.7627

Categorías

Más información sobre Code Generation en Centro de ayuda y File Exchange.

Preguntada:

el 19 de Oct. de 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by