MATLAB: How to add constraint with condtions using fmincon

fminconMATLAB

I have am optimization problem with two variables x and y where x and y are vectors.
I would like to add the foollowing constraint to fmincon :
if a<b then x<y
where a and b are known values.
I would like also to add in general x<y for every value of both vectors.
Many thanks!

Best Answer

Your constraint could be written as:
x-y < 1/(a<b)-1
when a<b, a<b=1, so, 1/(a<b)-1=0
when a>=b, a<b=0, so, 1/(a<b)-1=Inf, it is equivalent to not having constraint.