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

3 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 2 Mär. 2017
Yes, you just need a minor change: fun=@(x)F1(x)./F2(x)

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by