Finding minimum point from any function file input.

7 views (last 30 days)
Given ANY function file input, which we can assume to be continuous between [1,2], what is the code to estimate the x-value where the graph achieves its minimum point?

Answers (2)

Matt Kindig
Matt Kindig on 9 Oct 2013
Edited: Matt Kindig on 9 Oct 2013
I would check out the documentation for fminsearch() and fminbnd(), or if you have the Optimization Toolbox, fminunc():
doc fminsearch
doc fminbnd
doc fminunc
For example, if your function is f(x)=sin(x), you can call it like this:
sol = fminbnd(@sin, 1, 2)
Matt Kindig
Matt Kindig on 9 Oct 2013
Are the f(x) functions pre-defined, or can they be literally anything? If they can be anything, this problem is impossible to solve, as there are an infinite number of f(x) functions possible.
What exactly is your goal here?

Sign in to comment.

Matt J
Matt J on 9 Oct 2013
Edited: Matt J on 9 Oct 2013
If f(x) is vectorized, you would just do
[minval,minloc] = min(f(1:0.1:2))
If you can't rely on it being vectorized, you would have to loop
for i=1:length(m)


Find more on Optimization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by