efficiently compute the numerical solution of an ODE on a set of points?



 Science > Physics > efficiently compute the numerical solution of an ODE on a set of points?

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: Science > Physics
User: "Mike"
Date: 19 May 2007 12:46:56 AM
Object: efficiently compute the numerical solution of an ODE on a set of points?
Hi all,
I guess this is more of a programming question, but I am hoping to find some
deeper theoretical results:
The "ode45" of Matlab and other functions solve ODE numerically on a range
of points, such as in the following example:
Example
[t,y]=ode45(@vdp1,[0 20],[2 0]);
plot(t,y(:,1));
solves the system y' = vdp1(t,y), using the default relative error
tolerance 1e-3 and the default absolute tolerance of 1e-6 for each
component, and plots the first component of the solution.
Here [0, 20] is a range of the "t" variable...
Now what if I want the solution on a set of discrete data points.
Programmatically, I can of course call the above ODE multiple times, or
compute a range first and then sift out some point values...
But those are not efficient, is there an efficient way inside Matlab and/or
outside Matlab can allow me to solve ODEs on a set of data points more
efficiently?
Thanks!
.

User: "andy2O"

Title: Re: efficiently compute the numerical solution of an ODE on a set of points? 19 May 2007 04:29:21 AM
On 19 May, 06:46, "Mike" <meathea...@gmail.com> wrote:

Hi all,

I guess this is more of a programming question, but I am hoping to find some
deeper theoretical results:

The "ode45" of Matlab and other functions solve ODE numerically on a range
of points, such as in the following example:

Example
[t,y]=ode45(@vdp1,[0 20],[2 0]);
plot(t,y(:,1));
solves the system y' = vdp1(t,y), using the default relative error
tolerance 1e-3 and the default absolute tolerance of 1e-6 for each
component, and plots the first component of the solution.

Here [0, 20] is a range of the "t" variable...

Now what if I want the solution on a set of discrete data points.

Programmatically, I can of course call the above ODE multiple times, or
compute a range first and then sift out some point values...

But those are not efficient, is there an efficient way inside Matlab and/or
outside Matlab can allow me to solve ODEs on a set of data points more
efficiently?

Thanks!

When I want to find out how to do something in Matlab the first thing
I do is to read the help files.... it's what they're there for after
all. To quote from the *first* page of the documentation for ode45:
[T,Y] = ode45(odefun,tspan,y0)
[T,Y] = ode45(odefun,tspan,y0,options)
and tspan is described as:
"A vector specifying the interval of integration, [t0,tf]. The solver
imposes the initial conditions at tspan(1), and integrates from
tspan(1) to tspan(end). To obtain solutions at specific times (all
increasing or all decreasing), use tspan = [t0,t1,...,tf]."
So, in your code replace [0 20] with an array containing the output
times you want.
Yours,
andy
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1612     pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER