I am trying to approximate the global minimum of a function within a given domain, and the index of that global minimum.

1 view (last 30 days)
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?)

Answers (1)

dpb
dpb on 30 Sep 2017
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.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!