没有合适的资源?快使用搜索试试~ 我知道了~
matlab中ode45函数编写.pdf
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 42 浏览量
2021-09-14
16:03:20
上传
评论
收藏 285KB PDF 举报
温馨提示
试读
11页
。。。
资源推荐
资源详情
资源评论
function varargout = ode45(ode,tspan,y0,options,varargin)
%ODE45 Solve non-stiff differential equations, medium order method.
% [TOUT,YOUT]= ODE45(ODEFUN,TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates
% the system of differential equationsy' = f(t,y) from time T0 to TFINAL
% with initial conditions Y0. ODEFUN is a function handle. For a scalar
T
% and a vector Y, ODEFUN(T,Y) must return a column vector corresponding
% to f(t,y). Each row in the solution array YOUT corresponds to a time
% returned in the column vector TOUT. To obtain solutions at specific
% times T0,T1,...,TFINAL (all increasing or all decreasing), use TSPAN =
% [T0 T1 ... TFINAL].
%
% [TOUT,YOUT] = ODE45(ODEFUN,TSPAN,Y0,OPTIONS) solves as above with
default
% integrationproperties replaced by values in OPTIONS, an argument created
% with the ODESET function. See ODESET for details. Commonly used options
% arescalar relative error tolerance 'RelTol' (1e-3 by default) and vector
% of absolute error tolerances 'AbsTol' (all components 1e-6 by default).
% If certain components of the solution must be non-negative, use
% ODESET to set the 'NonNegative' property to the indices of these
% components.
%
% ODE45 can solve problems M(t,y)*y' = f(t,y) with mass matrix M that is
% nonsingular. Use ODESET to set the 'Mass' property to a function handle
% MASSif MASS(T,Y) returns the value of the mass matrix. If the mass matrix
% is constant, the matrix can be used as the value of the 'Mass' option.
If
% the mass matrix does not depend on the state variable Y and the function
% MASS is to be called with one input argument T, set 'MStateDependence'
to
% 'none'.ODE15S and ODE23T can solve problems with singular mass matrices.
%
% [TOUT,YOUT,TE,YE,IE]= ODE45(ODEFUN,TSPAN,Y0,OPTIONS) with the 'Events'
% property in OPTIONS set to a function handle EVENTS, solves as above
% while also finding where functions of (T,Y), called event functions,
% are zero. For each function you specify whether the integration is
% to terminate at a zero and whether the direction of the zero crossing
% matters. These are the three column vectors returned by EVENTS:
% [VALUE,ISTERMINAL,DIRECTION]= EVENTS(T,Y). For the I-th event function:
% VALUE(I)is the value of the function, ISTERMINAL(I)=1 if the integration
% is to terminate at a zero of this event function and 0 otherwise.
% DIRECTION(I)=0 if all zeros are to be computed (the default), +1 if only
% zeros where the event function is increasing, and -1 if only zeros where
% the event function is decreasing. Output TE is a column vector of times
% at which events occur. Rows of YE are the corresponding solutions, and
% indices in vector IE specify which event occurred.
%
% SOL = ODE45(ODEFUN,[T0 TFINAL],Y0...) returns a structure that can be
% used with DEVAL to evaluate the solution or its first derivative at
% any point between T0 and TFINAL. The steps chosen by ODE45are returned
% in a row vector SOL.x. For each I, the column SOL.y(:,I) contains
% thesolution at SOL.x(I). If events were detected, SOL.xe is a row vector
% of points at which events occurred. Columns of SOL.ye are the
corresponding
% solutions, and indices in vector SOL.ie specify which event occurred.
%
% 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.
%
% Class support for inputs TSPAN, Y0, and the result of ODEFUN(T,Y):
% float: double, single
%
% See also
% otherODE solvers: ODE23,ODE113, ODE15S, ODE23S, ODE23T, ODE23TB
% implicit ODEs: ODE15I
% options handling: ODESET, ODEGET
% output functions: ODEPLOT, ODEPHAS2, ODEPHAS3, ODEPRINT
% evaluating solution: DEVAL
% ODE examples: RIGIDODE, BALLODE, ORBITODE
% function handles: FUNCTION_HANDLE
%
% NOTE:
% The interpretation of the first input argument of the ODE solvers and
% some properties available through ODESET have changed in MATLAB 6.0.
% Although we still support the v5 syntax, any new functionality is
% available only with the new syntax. To see the v5 help, type in
% the command line
% more on, type ode45, more off
% NOTE:
% This portion describes the v5 syntax of ODE45.
%
% [T,Y] = ODE45('F',TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates the
% system of differential equations y' = F(t,y) from time T0 to TFINAL with
% initial conditions Y0. 'F' is a string containing the name of an ODE
% file. Function F(T,Y) must return a column vector. Each row in
% solution array Y corresponds to a time returned in column vector T. To
% obtain solutions at specific times T0, T1, ..., TFINAL (all increasing
% or all decreasing), use TSPAN = [T0 T1 ... TFINAL].
%
% [T,Y] = ODE45('F',TSPAN,Y0,OPTIONS) solves as above with default
% integration parameters replaced by values in OPTIONS, an argument
% created with the ODESET function. See ODESET for details. Commonly
% used options are scalar relative error tolerance 'RelTol' (1e-3 by
% default) and vector of absolute error tolerances 'AbsTol' (all
% components 1e-6 by default).
%
% [T,Y] = ODE45('F',TSPAN,Y0,OPTIONS,P1,P2,...) passes the additional
% parameters P1,P2,... to the ODE file as F(T,Y,FLAG,P1,P2,...) (see
% ODEFILE). Use OPTIONS = [] as a place holder if no options are set.
%
% It is possible to specify TSPAN, Y0 and OPTIONS in the ODE file (see
% ODEFILE). If TSPAN or Y0 is empty, then ODE45 calls the ODE file
% [TSPAN,Y0,OPTIONS] = F([],[],'init') to obtain any values not supplied
% in the ODE45 argument list. Empty arguments at the end of the call list
% may be omitted, e.g. ODE45('F').
%
% ODE45 can solve problems M(t,y)*y' = F(t,y) with a mass matrix M that
is
% nonsingular. Use ODESET to set Mass to 'M', 'M(t)', or 'M(t,y)' if the
% ODE file is coded so that F(T,Y,'mass') returns a constant,
% time-dependent, or time- and state-dependent mass matrix, respectively.
% Thedefault value of Mass is 'none'. ODE15S and ODE23T can solve problems
% with singular mass matrices.
%
% [T,Y,TE,YE,IE] = ODE45('F',TSPAN,Y0,OPTIONS) with the Events property
in
% OPTIONS set to 'on', solves as above while also locating zero crossings
% of an event function defined in the ODE file. The ODE file must be
% coded so that F(T,Y,'events') returns appropriate information. See
% ODEFILE for details. Output TE is a column vector of times at which
% events occur, rows of YE are the corresponding solutions, and indices
in
% vector IE specify which event occurred.
%
% See also ODEFILE
% ODE45 is an implementation of the explicit Runge-Kutta (4,5) pair of
% Dormandand Prince called variously RK5(4)7FM, DOPRI5, DP(4,5) and DP54.
% It uses a "free" interpolant of order 4 communicated privately by
% Dormand and Prince. Local extrapolation is done.
% Details are to be found in The MATLAB ODE Suite, L. F. Shampine and
% M. W. Reichelt, SIAM Journal on Scientific Computing, 18-1, 1997.
% Mark W. Reichelt and Lawrence F. Shampine, 6-14-94
% Copyright 1984-2009 The MathWorks, Inc.
% $Revision: 5.74.4.10 $ $Date: 2009/04/21 03:24:15 $
solver_name = 'ode45';
% Check inputs
if nargin < 4
options = [];
if nargin < 3
y0 = [];
if nargin < 2
tspan = [];
if nargin < 1
error('MATLAB:ode45:NotEnoughInputs',...
'Not enough input arguments. See ODE45.');
end
end
end
end
% Stats
nsteps = 0;
nfailed = 0;
nfevals = 0;
% Output
FcnHandlesUsed = isa(ode,'function_handle');
output_sol = (FcnHandlesUsed && (nargout==1)); % sol = odeXX(...)
output_ty = (~output_sol && (nargout > 0)); % [t,y,...] = odeXX(...)
剩余10页未读,继续阅读
资源评论
苦茶子12138
- 粉丝: 1w+
- 资源: 6万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于matlab实现字符识别的参考程序,用所用的字体识别率挺高,部分手写的也能识别,但是还不能识别扭曲和倾斜的字符 .rar
- 基于matlab实现指纹识别系统 包括数据库导入、图像选择识别、帮助功能、识别图像可视、gabor滤波可视,实现界面操作.rar
- 基于matlab实现指纹识别,利用gabor滤波器,提取指纹特征,只能呢读取bmp图像.rar
- 基于matlab实现于数字图像相关方法中散斑质量评价
- 基于matlab实现遗传算法和佳点集遗传算法的基本思想和不同点,用遗传算法测试一标准函数 佳点集算法测试一标准函数
- tensorflow-gpu-2.5.1-cp38-cp38-manylinux2010-x86-64.whl
- tensorflow-gpu-2.5.0-cp39-cp39-manylinux2010-x86-64.whl
- tensorflow-gpu-2.5.2-cp39-cp39-manylinux2010-x86-64.whl
- 内含方正小标宋简体、仿宋-Gb2312、黑体、楷体、宋体,五个公文常用字体
- 记忆卡牌游戏源码及可运行文件
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功