optimization with fminsearch error
조회 수: 2 (최근 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
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File 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!