How to use fmincon when the objective function is an expression of other functions?.

3 visualizaciones (últimos 30 días)
I am trying to minimize a function of two variables (defined over a compact interval [0,1]) using fmincon. However the objective function is really complicated in terms of length. I am trying to avoid writing it entirely by splitting it in shorter expressions. For instance, suppose my objective function is
fun=@(x) (x(1).^2+2)./(sqrt(x(2)+1))
What I am trying to do is to define, say
F1=@(x)(x(1).^2+2)
F2=@(x)(sqrt(x(2)+1))
and then minimize this new objective function fun=@(x)F1./F2
Is it possible to do it?
Thanks in advance
Edoardo

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Mzo. de 2017
Yes, you just need a minor change: fun=@(x)F1(x)./F2(x)

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by