fminbnd finding wrong minimum point for no reason, please help

1 回表示 (過去 30 日間)
Emre
Emre 2011 年 10 月 19 日
f = @(x)(-(1.0/((x-0.3).^2+0.01)+1.0/((x-0.9).^2+0.04)));
x = fminbnd(f, -1, 2);
x
y=f(x);
y
x = -1:0.3:2
y = -(1./((x-0.3).^2+0.01)+1./((x-0.9).^2+0.04))
plot(x,y)
here, minimum of the function should be smt between -50 and -60, but it finds -102.5014!! Why is that? please help.

採用された回答

Andrei Bobrov
Andrei Bobrov 2011 年 10 月 19 日
f = @(x)(-(1.0./((x-0.3).^2+0.01)+1.0./((x-0.9).^2+0.04)));
x1 = fminbnd(f, -1, 2);
x1
y=f(x1);
y
x = sort([-1:0.3:2,x1])
y = -(1./((x-0.3).^2+0.01)+1./((x-0.9).^2+0.04))
plot(x,y)
  3 件のコメント
Andrei Bobrov
Andrei Bobrov 2011 年 10 月 19 日
due to the choice of x
Andrei Bobrov
Andrei Bobrov 2011 年 10 月 19 日
use
ezplot(f,[-1,2,f(x1)-.2,0])

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 10 月 19 日
As was indicated more than once in resposne to your previous question, you are trying to apply fminbnd() to a problem with multiple minima, but fminbnd() is not designed to handle such situations.
If you want to handle functions like the one above, you need a global minimizer.

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by