Newcnstr( evalin( 'caller', 'cvx_problem', '[]' ), x, y, '>=' );

I keep getting this error when trying to use a flat parabola function as my objective function:

f(x) = 0, a<=x<=b;
= x^2, otherwise

I am using matlab function handle to define it:
f = {@(var)((2*(var-Tu(i))^2).(var>=Tu(i)) + (0).(and(Tl(i)<=var,var<=Tu(i))) + (2*(var-Tl(i))^2).*(var<=Tl(i)))};
This handle works fine with fmincon().

Can someone please suggest any other way that I can express this function? I will be using a sum of such functions as my final objective function.

Thanks a lot for the help.

FAQ: Why doesn’t CVX accept my problem? [READ THIS FIRST]

You need to read the manual, and the FAQ above. You cannot use CVX like you use fmincon.