Variable range change

In the first objective function, I want the range of the variable pch to be between -7 and 7, but in the second objective function, we want only the negative values (0 -7) of this pch variable to be considered in the objective function. Is this possible?

  cvx_begin ;
              cvx_solver Mosek 
                  
                    variable pch(10,24)
                   
             minimize (sum(b(i).*pch+a(i)*pch.^2))+sum(sum(uBD*pch(**just negetive values**)))

             subject to
                    -7<=pch<=7;

Perhaps you are looking for -pos(-pch) in the 2nd term? That is concave, so unless uBD <= 0, the 2nd term of the objective function won’t be convex, in which case you will have to resort to use of binary variables to model the non-convex use of max, specifically, -max(-pch,0) (which is what -pos(-pch) is.
You’ll need this to be implemented on per element of pch. I leave the details to you.

See 'y = max(x)` in Logics and integer-programming representations - YALMIP

Thanks. No . the variable pch for the first term should be defined between -7 and 7, but the same variable pch should be defined between -7 and 0 for the second semester. (For some reason, I don’t want to define a new variable for the second term.) And values that are considered positive due to the first term should be considered zero in the second term. something like that for second term: pch(pch>0)=0

cvx_begin ;
              cvx_solver Mosek 
                  
                    

variable pch(10,24)
                   
             minimize (sum(b(i).*pch+a(i)*pch.^2))+sum(sum(uBD*pch))

             subject to
                    -7<=pch<=7;

isn’t that what -pos(-pch) or -max(-pch,0) does? Note that as written, the max formulation so not correct when applied to a matrix.