0

I have a system of ODE's. The ODE takes a couple of seconds to run in a particular parameter range. For another parameter range, however, MATLAB suddenly takes an infinite amount of time to run (well, ok, only tested to half a day).

This is a complex, multiply coupled ODE with hyperbolic functions; solving it analytically is impossible, solving it numerically would be a master's thesis, so I'm looking for a computational solution. I need to throw out such parameters and move to the next (random) set of parameters.

How would I debug or catch this semantic error in MATLAB? I'm just not sure what odesolver doesn't like about it. So far, I've used profiler to narrow it down to these lines in odesolver:

 f(:,2) = feval(odeFcn,t+hA(1),y+f*hB(:,1),odeArgs{:}); 
 f(:,3) = feval(odeFcn,t+hA(2),y+f*hB(:,2),odeArgs{:}); 
 f(:,4) = feval(odeFcn,t+hA(3),y+f*hB(:,3),odeArgs{:}); 
 f(:,5) = feval(odeFcn,t+hA(4),y+f*hB(:,4),odeArgs{:}); 
 f(:,6) = feval(odeFcn,t+hA(5),y+f*hB(:,5),odeArgs{:});\

(which is essentially the core solver method). Obviously the source of the error is my choice of parameters, but profiler does not show any noticeable time taken up by my function (I pass a script function of the ODE as an anonymous function to ode45).

Keegan Keplinger
  • 627
  • 5
  • 15
  • Hyperbolic functions? Are you sure `ode45` is the appropriate solver? If this is a stiff system you should try `ode15s`. Just because you got a result doesn't necessarily mean it's the correct result, especially since the system seems to a be difficult one. Have you adjusted the integration tolerances (`'AbsTol'` and `'RelTol'`) and confirmed that you still get the same trajectories? Have you looked at the `'Stats'` to see the number of failed steps. Lastly, look at [this recent question and answer](http://stackoverflow.com/questions/17537254/) which might be helpful. – horchler Jul 13 '13 at 17:16
  • The failed steps can be anywhere from 0 out 5000 to 190 out of 11000 depending on the parameters used. The results are correct in known parameter ranges of ode45, but part of the difficulty is that other parameter ranges may cause instabilities. The assumption I'm operating under is that where these instabilities exist are outside the parameter region of interest anyway, so those parameters can be skipped (thus a catch..break routine would be nice). I have a test that explicitly tests each parameter set, so if `ode15s` would allow the solver to finish I could throw them out with my test. – Keegan Keplinger Jul 13 '13 at 18:33
  • so far `ode15s` is working. It could be, by chance, that I haven't run across a bad a parameter range but it's made it a lot further than `ode45` did before hanging. Thanks. – Keegan Keplinger Jul 13 '13 at 18:50

0 Answers0