I am trying to approximate the global minimum of a function within a given domain, and the index of that global minimum.
1 次查看(过去 30 天)
显示 更早的评论
Inputs:
Func - an arbitrary function. eg. @(x) x.^2 + 4
xStart - The first x value in the function domain
xEnd - The last x value in the function domain
Outputs:
yMin - The global minimum of the function within a given domain
index - The index for the global minimum of the function (ie. in what
position of the y vector was yMax located?)
0 个评论
回答(1 个)
dpb
2017-9-30
Well, that'll only be as good as the granularity of the points at which you evaluate the function but
x=[x0:dx:x1];
[xmin,idxmin]=min(func(x));
will do what your problem description is given an arbitrary dx. Or you could write as
x=linspace(x0,x1,Npts);
given an arbitrary number of points between the two ranges, Npts
Alternatively, you might consider
doc fminsearch
that will return the minimum of the function itself independent of some arbitrary evaluation vector.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!