help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Octave ode45 vs. Matlab ode45


From: Stephen Montgomery-Smith
Subject: Re: Octave ode45 vs. Matlab ode45
Date: Fri, 14 Jun 2013 20:58:02 -0500
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130510 Thunderbird/17.0.6

On 06/14/2013 02:44 PM, Torsten wrote:
> On 14.06.2013 21:22, Jeffrey wrote:
>> I'm getting different results from Octave's ode45 than from Matlab's. I
>> also need to vary ode45's tolerance level, but I'm getting the following
>> messages:
>>
>> warning: Option "RelTol" will be ignored if fixed time stamps are given
>> warning: Option "AbsTol" will be ignored if fixed time stamps are given
>>
>> What do these messages mean? How do I properly set the tolerance? The
>> documentation I can find indicates that 'time stamps' have to do with the
>> time stamps of my source files. So not related to ode solving.
>>
>> Here is how I set the tolerance:
>> tol=1e-8;
>> options=odeset('Stats','on');
>> options=odeset(options,'AbsTol',tol);
>> options=odeset(options,'RelTol',tol);
>> [t,u1]=ode45(@(t,y) f(t,y,beta), t; [u0;v0], options);
>>
> 
> I guess "time stamps" means that you have a vector of time instances as
> time parameter t instead of an interval ([t_begin, t_end]). In the
> latter case, ode45 can chose the grid points in order to match the
> tolerances. For a time vector, this grid is fixed.
> 
> Torsten

I agree with Torsten.  I think the documentation provided by "help
ode45" is rather hard to understand.  But looking at the source code of
ode45.m shows that you get the above warning messages if the input t
contains more than 2 elements.

If t contains only two elements, then ode45 solves the ode at time
intervals set so that it can be sure that RelTol and AbsTol are
satisfied by the solution.  Then it solves the ODE from time t(1) to t(2).

If t contains more than two elements, then it uses those elements to
determine the time intervals used by the time solver.

I am told that Matlab ode45 works differently.  What it does is to solve
the ODE the same way irrespective of the length of t, and then uses a
spline to figure out the value of the function at all the time slots.

If you want to get octave ode45 to do the same as matlab ode45, I
suggest you run ode45 with [t(1) t(end)] for the time slot, and then put
the output of ode45 into the spline command with the third input set to t.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]