0

I'm trying to figure out the order of convergence for my exact problem using both ode45 and ode23s in matlab.

To do so i'm using

options = odeset('InitialStep',dt,'RelTol',Inf,'AbsTol',Inf,'MaxStep',dt,'Stats','on');

[~,y] = ode23s(@funode,[time(1):dt:time(end)],init,options);

to control the step size.

This works just fine on the problems I have tested it on for ode23s, but of some reasons not for ode45. Were I just lucky that it worked on ode23s? what am I doing wrong? or why is it not working on ode45?

Veve
  • 6,643
  • 5
  • 39
  • 58
Nicky Mattsson
  • 3,052
  • 12
  • 28
  • How do you know is not working with `ode45`? –  Nov 24 '14 at 15:45
  • When I used [~,y] = ode23s(@funode,[time(1),time(end)],init,options); I got to many steps as output – Nicky Mattsson Nov 24 '14 at 16:16
  • 1
    Yes, again, that is about `ode23s`. :-) You didn't say anything about how `ode45` performed. Did you get a different solution? What did you expected from the `ode45` call? –  Nov 24 '14 at 16:26
  • 1
    What is "work" and "doesn't work"? Say what works and what doesn't. Runnable code to illustrate your issue would be helpful. Does your set of `odeset` options actually fix the solver's true step size (as opposed to the output step size) ([see this question/answer for possible clarification](http://stackoverflow.com/questions/21859870/absolute-error-of-ode45-and-runge-kutta-methods-compared-with-analytical-solutio))? – horchler Nov 24 '14 at 17:35
  • When I run the ode45 solver with the above mentioned options on a test problem such as yprime(t,y) = y, and y(0) = 1. Such that I ex. have: [t,y] = ode45(@(~,y) y, [0,10],1,options). Then the vector containing the times is longer than (10-0)/dt, telling that the adaptivity in ode45 is changing the step size, which I don't want it to. When I run the same problem with ode23s(@(~,y) y,[0,10],1,options) then the vector containing the times is of the correct length corresponding to that the method is using the step size that I want it to. – Nicky Mattsson Nov 24 '14 at 17:45

0 Answers0