Hello, I would appreciate if someone help me.
My problem is that I have 5 polyonimals and I made them switch when the value reaches umax it switch to the next one, but I want to stay there or move forwand to the next one polyonimal.
I did the following code, the problem is ode calls this function at each loop and u1max,u2max,u3max,u4max,u5max keeps getting refreshing.
function udot = ok3(t,u,p1,p2,p3,p4,p5,m,maxu,maxT,u1max,u2max,u3max,u4max,u5max)
syms z p(z)
T=symsum(p(m+1-z)*(u(1))^z,z,0,m);
if u(1)<=u1max
for y=1:m+1
T=subs(T,p(y),p1(y));
end
elseif u(1)<=u2max
u1max=5000;
for y=1:m+1
T=subs(T,p(y),p2(y));
end
elseif u(1)<=u3max
u1max=5000; u2max=5000;
for y=1:m+1
T=subs(T,p(y),p3(y));
end
elseif u(1)<=u4max
u1max=5000; u2max=5000; u3max=5000
for y=1:m+1
T=subs(T,p(y),p4(y));
end
elseif u(1)<=u5max
u1max=5000; u2max=5000; u3max=5000; u4max=5000;
for y=1:m+1
T=subs(T,p(y),p5(y));
end
else
T=maxT;
u(1)=maxu;
end
.
.
.
.
udot=double([SM1;SF]);
end