optimization with fminsearch error

조회 수: 2 (최근 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 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