help-octave
[Top][All Lists]
Advanced

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

Re: ode45


From: Kai Torben Ohlhus
Subject: Re: ode45
Date: Mon, 29 Jul 2013 09:49:02 +0200

Hi,

I think your problem has a mathematically nature. You want to solve an ODE with no change in either direction on some time interval. The solution is trivial: It's a straight line, as Octave and MATLAB reveal.

Here the code I used:

[CODE]
clear all
close all
clc

% y1' = 0;
% y2' = 0;
odefunction2 = @(Z,y) [0; 0]; % Trivial, no change in either direction y1, y2

z0 = -248;
Z = [0 -700]/z0;

y0 = [31112 0];

A = odeset('RelTol',1e-5,'AbsTol',1e-5,'InitialStep',1e-2,'MaxStep',1e-2);

[tt,yy] = ode23s (odefunction2, Z, y0, A);

plot (tt, yy)
[/CODE]

In MATLAB ode45 can handle this problem (with the same result as ode23s), but ode45 has to do many small steps that aren't required for such an trivial solution. MATLAB and Octave produce the trivial solution for any initial condition faster when using a stiff solver like ode23s, that seems to be more appropiate for you mathematical problem.

Kai

reply via email to

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