optimization with fminsearch error
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
sensation
am 28 Aug. 2017
Kommentiert: sensation
am 30 Aug. 2017
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 Kommentare
Akzeptierte Antwort
Alan Weiss
am 28 Aug. 2017
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Get Started with Optimization Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!