optimization with fminsearch error

3 ビュー (過去 30 日間)
sensation
sensation 2017 年 8 月 28 日
コメント済み: sensation 2017 年 8 月 30 日
Hi,
I am trying to optimize my function with fminsearch in order to find a minimum. My function is of a form:
function v_max_diff = objFcn(ah25)
%OBJFCN
% V_MAX_DIFF = OBJFCN(AH25)
% This function was generated by the Symbolic Math Toolbox version 7.0.
% 28-Aug-2017 17:36:10
v_max_diff = 5.0.^(-ah25).*6.25e6-1.25e6;
when I run fminsearch like:
[x(:,i),fval(:,i)] = fminsearch(fun,1,options)
I get x=26.55 and fval=-1250000.
I want to minimize my fun v_max_diff by searching for an optimized ah25 so that the whole result approaches zero and not to fval of -125000 as in the present case.
I am new to optimization so any hint is more than appreciated.
thanks

採用された回答

Alan Weiss
Alan Weiss 2017 年 8 月 28 日
Your function as written is monotone decreasing in the variable ah25, and asymptotically approaches -1.25e6 as ah25 gets large. I am not at all sure that this is what you intended your function to do, but that is what it does.
If, instead, you want to find a zero of your function, use fzero instead of fminsearch, because fminsearch looks for a minimum of your function, which, as I just told you, is approximately -1.25e6 for all large enough values of ah25.
Of course, your function is simple enough that you don't need to use fzero to find a root. Inspection shows that ah25 = 1 is the unique solution.
Alan Weiss
MATLAB mathematical toolbox documentation
  1 件のコメント
sensation
sensation 2017 年 8 月 30 日
Thanks Alan for this brief explanation. Actually I have many other points so fzero does the job:). Cheers

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Optimization Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by