If-else statement

Hi,
I have a problem with if-else statement which leads to “Disciplined convex programming error: Constraints may not appear in if/then statements.”
Could you please help to fix it? As recommend in community page, I checked big M Modelling as well as MIDCP. I still cannot understand how to solve the problem unfortunately.

cvx_begin
variable V1x(length(t))
for i=1:length(t)
IL(i)=-V1x(i)/Rs;
end

for i=1:length(t)
if Vs1(i)>=Vdd-Vtp
Ip(i)=0;
elseif V1x(i)>Vdd-Vdsatp(i)
Ip(i)=Idsatp(i)(1+lambdap(Vdd-V1x(i)))(2-((Vdd-V1x(i))/(Vdd-Vdsatp(i))))((Vdd-V1x(i))./(Vdd-Vdsatp(i)));
else V1x(i)<=Vdd-Vdsatp(i)
Ip(i)=Idsatp(i)(1+lambdap(Vdd-V1x(i)));
end
end

IR=Ip-(Cm+Cd)*V1x;

minimize(norm(IL-IR,2));

cvx_end

Note: All parameters such as t,Vdd, Idsatp, Vdsatp, lambdap, Vtp, Rs, Vs1, Cm, and Cd are defined as constants before cvx_begin.

Look at the links on https://or.stackexchange.com/search?q=logic+modeling , and ask there for any assistance.

Thank you for your reply and the provided link. I checked it out and asked my question there, although I have not yet received any reply.
Could you please clarify if cvx has the capability to solve such a problem or you would recommend me to try other optimization method/tool?

Apparently your question https://or.stackexchange.com/questions/5282/if-else-statement-in-cvx was not well-received. I suggest rewriting it without reference to CVX, and inquire how to use Big M to handle the logic modeling. Describe your model mathematically, not as CVX code. f you show some effort, your question may be better received.

Did you look at the question and answers per the link I provided. I suggest you do that.

This should be doable in CVX provided you have Mosek or Gurobi available as a solver.