Bug fminbnd not working

2 ビュー (過去 30 日間)
Stephen Wilkerson
Stephen Wilkerson 2019 年 1 月 20 日
編集済み: Torsten 2022 年 7 月 17 日
fplot(@(x) x*(sin(x))^2*cos(x),[-2*pi 2*pi]);
[xMin1 fvalmin1] = fminbnd('-x*(sin(x))^2*cos(x)', -6, 6)
returns xMin1 = 1.0954
fvalmin1 = -0.3963
How is this possible, look at the plot?
  3 件のコメント
Stephen Wilkerson
Stephen Wilkerson 2019 年 1 月 20 日
Not where the minimum is! look at the plot
Stephen Wilkerson
Stephen Wilkerson 2019 年 1 月 20 日
Solved, The function doesn't really do much, it give you the nearest point that's a minimum to it's starting point. In my case it woud be 0 as the starting point. Typical

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

採用された回答

Walter Roberson
Walter Roberson 2019 年 1 月 20 日
No bug. fminbnd is a local minimizer, not a global minimizer.
  3 件のコメント
Torsten
Torsten 2022 年 7 月 17 日
編集済み: Torsten 2022 年 7 月 17 日
Since the changes in the x-values are in the order of 1e-6, you must choose a smaller value for TolX:
a=-200; b=-979.8997; c=7.1833e+05; d=24.4232;e=-6.6083;
x1=0; x2=4.1135e-06;
f=@(x)a-(a-b)*cos(c*(x-x1)) + d*e*sin(c*(x-x1))
f = function_handle with value:
@(x)a-(a-b)*cos(c*(x-x1))+d*e*sin(c*(x-x1))
fplot(f, [x1 x2])
options = optimset('TolX',1e-8);
[xmin, min]=fminbnd(f, x1, x2, options)
xmin = 2.8422e-07
min = -996.4246
Zhe Yu
Zhe Yu 2022 年 7 月 17 日
Hi Torsten, thank you very much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnalog Devices ADALM1000 Support from Data Acquisition Toolbox についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by