0
y(1)' = y(2);

y(2)' = [-y(1)-y(2)^2]/(y(1)+C0);

y(3)' = y(3)/y(4)*y(2)*C1;

y(4)' = y(2)*FF;

C0, C1, C2 and C3 are Const., FF is C2*y(3)^0.5 if y(3) > 100; FF is C3*y(3)^0.5 if y(3)<=100.

How to set y(4)' in this situation?

I tried y(4)' = y(2)*((y(3) > 100)*C2*y(3)^0.5 + (y(3)<=100)*C3*y(3)^0.5); It didn't work. Any suggestions?

Thank you in advance.

The equations above were simplified.

Well, after several tests with ode15s and other solvers, I realized that the matrix was close to singular. So the physical condition is the problem.

Ben
  • 1
  • 1
  • What you tried should work. Can you explain why it didn't and possibly provide the complete code so we can run it? – TroyHaskin Sep 15 '16 at 04:27
  • Please see the revised question and codes. Thank you so much. @TroyHaskin – Ben Sep 15 '16 at 17:23

0 Answers0