Finding minimum point from any function file input.

6 visualizaciones (últimos 30 días)
Jia Qing Soo
Jia Qing Soo el 9 de Oct. de 2013
Editada: Matt J el 9 de Oct. de 2013
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?

Respuestas (2)

Matt Kindig
Matt Kindig el 9 de Oct. de 2013
Editada: Matt Kindig el 9 de Oct. de 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)
  2 comentarios
Jia Qing Soo
Jia Qing Soo el 9 de Oct. de 2013
Is there another way of finding the minimum point?
For example, writing a code such as to input an x-value (from x = 1 to 2 with an interval of 0.1) to derive the corresponding f(x) and then getting matlab to figure out which f(x) is the minimum?
Matt Kindig
Matt Kindig el 9 de Oct. de 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?

Iniciar sesión para comentar.


Matt J
Matt J el 9 de Oct. de 2013
Editada: Matt J el 9 de Oct. de 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
x=1:0.1:2;
m=inf(size(t));
for i=1:length(m)
m(i)=f(x(i));
end
[minval,minloc]=min(m);

Categorías

Más información sobre Performance and Memory en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by