optimization with fminsearch error

1 次查看(过去 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 CenterFile Exchange 中查找有关 Get 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