Let us consider the function f(x), defined as f(x)=x for negative x+10, f(0)=10, and f(x)=ln(1+x)+10 for positive x. It is clear that f(x) is a concave and smooth function.

I coded it as

if x<0

f=x+10

else

f=ln(1+x)+10

end

maximize f

subject to blah blah blah

However, since x is posed in “if” statement, error occurs. Is there any method to implement CVX for the case where the objective function is differently defined according to design variable’s region.