dear professor,
I wanted to model this "if" struct below using "implies" operator:

finally I got NaN result in my code .However,after removing the "implies" constraints I can get a reasonable result . So I wonder what is wrong about my code below.thank you so much!
clear
s=100;
N=100;
ds=s/N;
v=sdpvar(1,N);
Te=sdpvar(1,N-1);
Tb=sdpvar(1,N-1);
soc=sdpvar(1,N);
d=binvar(2,1);
socdot=sdpvar(1,N-1);
opts=sdpsettings;
opts.solver = '';
opts.verbose = 0;
cons1=[];
cons2=[];
cons3=[];
cons4=[];
cons5=[];
cons6=[];
cons9=[];
obj1=[];
for i=1:N-1
vdot=[(Te(i)*19-Tb(i)-0.5*4000*9.8*0.02-0.5*0.5*2.5*0.3*1.29*v(i)^2)/(4000*0.5)];
cons1=[cons1,v(i+1)*v(i)==v(i)^2+ds*vdot];
cons2=[cons2,-500<=Te(i),Te(i)<=500];
cons3=[cons3,0<=Tb(i),Tb(i)<=0.5*4000*9.8*0.6];
cons4=[cons4,0<=v(i),v(i)<=10];
cons9=[cons9,sum(d) == 1,
implies(d(1), [Te(i) <= 0, socdot(i) == -(400-(160000-1444*v(i)*Te(i))^(0.5))/6200*v(i)]);
implies(d(2), [Te(i) >= 0, socdot(i) == -(400-(160000-1600*v(i)*Te(i))^(0.5))/6200*v(i)])];
% socdot= [-(400-(160000-1600*v(i)*Te(i))^(0.5))/6200*v(i)];
cons5=[cons5,soc(i+1)==soc(i)+socdot(i)*ds];
cons6=[cons6,0<=soc(i),soc(i)<=1];
obj1=[obj1,ds*cpower(v(i),-1)];
end
cons7=[v(1)==1,v(N)==1];
cons8=[soc(1)==1];
cons=cons1+cons2+cons3+cons4+cons5+cons6+cons7+cons8+cons9;
obj=sum(obj1);
sol = optimize(cons,obj,opts);
![OVC(2JQKA22SX1[ZJE8]~KG.png](https://groups.google.com/group/yalmip/attach/13340474861a7/OVC(2JQKA22SX1%5BZJE8%5D~KG.png?part=0.1&view=1)