Science > Physics > efficiently compute the numerical solution of an ODE on a set of points?
| 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
.
|
|
|
|

|
Related Articles |
|
|