How to solve CVX variable cannot do 'if' operation

How to solve CVX variable cannot do ‘if’ operation

Perhaps you can implement a logic constraint using Big M.

Search for
logic constraint

at https://or.stackexchange.com/

OK,I will try, thank you.