Matlab 版 (精华区)
发信人: candle ( 马 走 日), 信区: Matlab
标 题: How do I use a fixed step size with ODE23/45?
发信站: 紫 丁 香 (Fri Dec 24 17:43:16 1999), 转信
1503
How Do I Use a Fixed Step Size With
ODE23/ODE45?
Revison: 1.1
Last Date Modified: 29-June-1999
ode23 and ode45 are MATLAB's ordinary differential equation
solver functions. ode23 is based on the integration method, Runge
Kutta23, and ode45 is based on the integration method, Runge
Kutta45. The way that ode23 and ode45 utilize these methods is
by selecting a point, taking the derivative of the function at that
point, checking to see if the value is greater than or less than the
tolerance, and altering the step size accordingly. These integration
methods do not lend themselves to a fixed step size. Using an
algorithm that uses a fixed step size is dangerous since you may
miss points where your signal's frequency is greater than the
solver's frequency. Using a variable step ensures that a large step
size is used for low frequencies and a small step size is used for
high frequencies. ode23/ode45 are optimized for a variable step,
run faster with a variable step size, and clearly the results are
more accurate. If you wish to obtain only those values at a certain
fixed increment, do the following:
Use ode23/ode45 to solve the differential equation.
Use interp1 to extract only the desired points.
For example:
>> t0 = 0:.01:10; % the fixed step vector for desired
%output
>> [t,y] = ode23('filename',0,10);
>> y0 = interp1(t0,t,y);
Now, t0 and y0 are the outputs at a fixed interval.
Note that, in MATLAB 5, you can also obtain solutions at specific
time points by specifying 'tspan' as a vecotr of the desired times.
The time values must be in order, either increasing or decreasing.
For example:
>> tspan = 0:.01:10;
>> [t,y] = ode23('filename',tspan);
--
---------------------------------------------------
I BELIEVE I CAN FLY. I BELIEVE I CAN TOUCH THE SKY.
------------------- CANDLE --------------------
※ 来源:.紫 丁 香 bbs.hit.edu.cn.[FROM: 150.59.34.186]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.671毫秒