How to express if-else (indicator) constraints in cvx?

X is a variable and a is a constant. I want to achieve the following functionality:

if X <= 0
f = X + a;
else
f = a;
end

How can I express this constraint in cvx?

see


by the way, the function f you posted is concave to X, it can be expressd by f=(-abs(x)+x)/2+a; in cvx.

Or you can use the provided pos function as
-pos(-x) + a

Thank you very much!

Thank you very much! I forgot that there is a pos function