ode45 matlab ode45 步长编程问题 急求~!

ode45 matlab编程问题 急求~!_百度知道
ode45 matlab编程问题 急求~!
dy(1)=-[25*y(2)/(-y(3)-y(4))]*y(4);
dy(2)=[25*y(2)/(-y(3)-y(4))]*y(4)-0.13*y(2);
dy(3)=0.13*y(2)-0.05*y(3);
dy(4)=0.05*y(3);这是四个方程[47 0]这是初值要图像 t是90天
参考代码:function&zdy0&=&[47&0];ode45(@odefun,[0&90],y0)functio穿浮扁簧壮毫憋桐铂昆n&dy&=&odefun(t,y)dy&=&zeros(4,1);dy(1)=-(25*y(2)/(-y(3)-y(4)))*y(4);dy(2)=(25*y(2)/(-y(3)-y(4)))*y(4)-0.13*y(2);dy(3)=0.13*y(2)-0.05*y(3);dy(4)=0.05*y(3);
其他类似问题
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁查看: 2528|回复: 4|关注: 0
求助:Matlab的ode45函数的问题
我现在的问题是这样:已知方程如下:
z'=a*z^2+b*cos(t);a=[1 2 3 4 5] b=[1 2 3 4 5];z(0)=0
我用ode45该怎么编程才能得到a与b在不同组合下的z(t)的数值解。
求大大帮忙解答一下,谢谢!
[T,Z]=ode45('dsa',[0 20],0);
plot(T,Z,'*')
---------------------------------------------------
function dz=dsa(t,z)
a=[1 2 3 4 5];b=[1 2 3 4 5];
for ii=1:5
dz=a(ii)*z^2+b(ii)*cos(t);
[ 本帖最后由 ww711 于
21:10 编辑 ]
回复 2# ww711 的帖子
谢谢您的解答,按照你的程序应该有5组[T,Z]的,为什么只显示了一组[T,Z]呀,能让这5组[T,Z]都显示吗,谢谢!
在想中。。。。。。。。。
关注者: 15
回复 4# ww711 的帖子
dz=a(ii)*z^2+b(ii)*cos(t);
这样dz始终是一个值的。。。前面的循环都被覆盖了。
Powered by用MATLAB如何用ODE45求解如下微分方程_百度知道
提问者采纳
% 时间间隔0~15s,0],x) J= Tb=Fx=R=wdot=Tb&#47,终止时刻15w0=[0;J-Fx*R&#47。 % 初始化
[t.m 为名的程序文本文件;J:cleartspan=[0 15]%建立微分方程的,tspan.m函数文件并且保存function wdot=dif1(t,初始时刻0;,w0); 接着建立一个以simu.m 的内容为,w]=ode45('dif1&#39
提问者评价
谢啦 回家试试run
其他类似问题
按默认排序
其他1条回答
直接积分不就出来了吗,w=t*(T-FR)/J+w(0),是不是右端哪像含时间t啊
微分方程的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁查看: 2333|回复: 2|关注: 0
求助:关于ode45函数参数传递的问题
function fun=f(t,z,a,b,c,n)
fun=c*cos(t)-b*abs(cos(t))*z*abs(z)^(n-1)-b*cos(t)*abs(z)^2
。。。。。。。。。。。。。。。。。。。。。。。。。。。。
ode45('f',[0,2*pi],0,[],4,4,4,4)
其中a b c n是我想代入的参数
但是提示我错误如下:
??? Error using ==& f
Too many input arguments.
Error in ==& C:\MATLAB6p5\toolbox\matlab\funfun\private\odearguments.m
On line 104&&==& f0 = feval(ode,t0,y0,args{:});
Error in ==& C:\MATLAB6p5\toolbox\matlab\funfun\ode45.m
On line 155&&==& [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, args, ...
这是怎么回事我对ode45函数不太熟悉,求各位大大帮忙看看,谢谢了
ode45(@f,[0,2*pi],0,[],4,4,4,4)
改成这个试试
回复 2# hallowwar 的帖子
我找到原因了,谢谢!
把fun=f(t,z,flag,a,b,c,n)就行了
Powered bymatlab ode 45的代码是什么 不是如何使用 而是他们是如何编写ode45的 谢啦_百度知道
matlab ode 45的代码是什么 不是如何使用 而是他们是如何编写ode45的 谢啦
de45是数值分析中的一种计算方法,为了让计算机可以使用人们就开发了各种数值方法,白话点说就是一种计算机可以使用的积分方法,咱们计算积分的方法计算机不能用,具体课参考数值分析的书
其他类似问题
按默认排序
其他2条回答
TFINAL (all increasing%
or all decreasing),Y0; = F(t.&#39,Y0;) returns a constant. For each function you specify whether the integration is %
to terminate at a zero and whether the direction of the zero crossing %
matters,y,TE.
Use OPTIONS = [] as a place holder if no options are set,Y0;) returns appropriate information, ntspan. %%
[t, Inc, ODE23TB %
implicit ODEs,T1..
' f3d = [],Y0:%
This portion describes the v5 syntax of ODE45.
See ODE45, type ode45,YOUT] = ODE45(ODEFUN.sol = [];Not enough input arguments. (all components 1e-6 by default).
Each row in%
solution array Y corresponds to a time returned in column vector T.; (1e-3 by%
default) and vector of absolute error tolerances &#39: %
VALUE(I) is the value of the function... For the I-RelTol&#39.)% There might be no output requested., the matrix can be used as the value of the &#39, hmax, odeFcn, use TSPAN = %
[T0 T1 , ODE23S, 1997, and the result of ODEFUN(T; = f(t; if output_sol
sol.options = options. See ODESET for details,Y0) with TSPAN = [T0 TFINAL] integrates the%
system of differential equations y&#39,,. %
Class support for inputs TSPAN.xe is a row vector %
of points at which events occurred.
To see the v5 help,YE;NonNegative&#39, and indices in%
vector IE specify
components 1e-6 by default); is a string containing the name of an ODE%
if nargin &lt.y(;
% [t;on&#39. ODE15S and ODE23T can solve problems%
if nargin &MStateDependence&#39. %
[T, ODEPHAS2.; = vdp1(t,OPTIONS] = F([]matlab命令窗口 输入edit ode45即可看到下面的是部分代码 太长了 贴不下function varargout = ode45(ode.
Output TE is a column vector of times at which%
events occur. Sinit&#39,YOUT.) (see%
ODEFILE).74;);04&#47,y)'. 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;
% sol = odeXX(. ODE45(&#39, ODEGET%
output functions,Y),y)*y&#39,YE, BALLODE, SIAM Journal on Scientific Computing, ODE23T;%
property in OPTIONS set to a function handle EVENTS,[0 20].
ODEFILE for details... Each row in the solution array YOUT corresponds to a time %
returned in the column vector TOUT, tspan.%%
[T,y]=ode45(@vdp1,5) and DP54.%
See also ODEFILE %
ODE45 is an implementation of the explicit Runge-Kutta (4,[2 0]).; = F(t, options:
ODE23;F&#39, any new functionality is %
available only with the new syntax,TE;function_handle&#39,OPTIONS) solves as above with default%
integration parameters replaced by values in OPTIONS,y) from time T0 to TFINAL %
with initial conditions Y0;mass&#39.x(I);nfevals = nfevals + 1.;
% Handle solver arguments[neq,OPTIONS) with the &#39,5) pair of%
Dormand and Prince called variously RK5(4)7FM,P1;free&quot.ie specify which event occurred,y):ode45;output_sol = (FcnHandlesUsed && (nargout==1)),Y] = ODE45(&#39. Shampine and%
M;, single%%
See also %
other ODE solvers:15 $solver_name = &#39,, +1 if only %
zeros where the event function is increasing, Y0;F&#39.: 2009&#47, set &#39, 6-14-94%
The MathWorks, or ',Y] = ODE45(&#39, T1, rtol.; 2
tspan = []. Rows of YE are the corresponding solutions.,Y] = ODE45(&#39, ODEPRINT%
evaluating solution, and %
indices in vector IE specify
property to a function handle %
MASS if MASS(T. If the mass matrix %
is constant,Y). R;M'Events&#39, using the default relative error%
tolerance 1e-3 and the default absolute tolerance of 1e-6 for each%
component.,FLAG.%
$R).solver = solver_name, , use%
ODESET to set the &#39,. ODE15S and ODE23T can solve problems with singular mass matrices. %
DIRECTION(I)=0 if all zeros are to be computed (the default). W;
endend% Statsnsteps
Details are to be found in The MATLAB ODE Suite,OPTIONS) solves as above with default%
integration properties replaced by values in OPTIONS;M(t)&#39.%
Although we still support the v5 syntax,P2,Y) returns the value of the mass matrix:
ODEPLOT. The steps chosen by ODE45 are returned %
in a row vector SOL,.ye are the corresponding %
solutions. Use ODESET to set the &#39, SOL;nfevals = 0, t0,OPTIONS) with the Events property in%
OPTIONS set to &#39. Output TE is a column vector of times %
at which events occur.%
It uses a &quot,I) contains %
the solution at SOL.%
[TOUT;Mass&#39: 5.
odearguments(FcnHandlesUsed,y0.. ODEFUN is a function handle: %
The interpretation of the first input argument of the ODE solvers and %
some properties available through ODESET have changed in MATLAB 6,TSPAN.
&#39,TSPAN.
Function F(T.
See ODESET for details. Reichelt and Lawrence F.;
sol. TFINAL];
plot(t,Y,P2.varargin = varargin,y) with mass matrix M that is%
nonsingular, more off%
NOTE; 0)); 1
error(&#39.%
[T,; interpolant of order 4 communicated privately by%
Dormand and Prince., varargin), DP(4;nfailed = 0;,1)), ISTERMINAL(I)=1 if the integration %
is to terminate at a zero of this event function and 0 otherwise,%
time-dependent.. Commonly used options %
are scalar relative error tolerance &#39.%
Mark W;RelTol'AbsTol' to%
&#39.) passes the additional%
parameters P1., e, dataType] = ;F&#39, type in %
the command line
% (1e-3 by default) and vector%
of absolute error tolerances &#39,TSPAN.
For each I, and indices in vector SOL, called event functions.0, ODE15S,:
RIGIDODE,Y) must return a column vector.
[TOUT, htspan,y) with a mass matrix M that is%
nonsingular, ,options, solver_
options handling, tspan.) returns a structure that can be%
used with DEVAL to evaluate the solution or its first derivative at %
any point between T0 and TFINAL, y0,, use TSPAN = [T0 T1 .
used options are scalar relative error tolerance &#39, or time- and state-dependent mass matrix, DOPRI5,P2;; property to the indices of these%none&#39,y);%
solves the system y&#39,[T0 TFINAL]; 3
y0 = [],M(t., L:.%
The default value of Mass is &#39, f0:
ODE = f(t. to the ODE file as F(T.10 $
$Date,Y): double.;Mass&#39.,TSPAN:24. If events were detected, Y0 and OPTIONS in the ODE file (see%
ODEFILE). These are the three column vectors returned by EVENTS, the column SOL;F&#39, ODEPHAS3.%
[T,Y0) with TSPAN = [T0 TFINAL] integrates %
the system of differential equations y&#39, then ODE45 calls the ODE file%
[TSPAN,varargin)%ODE45
Solve non-stiff differential equations.
To obtain solutions at specific %
times T0,IE] = ODE45(ODEFUN..,,y) from time T0 to TFINAL with%
initial conditions Y0;MATLAB.4; if the%
ODE file is coded so that F(T, tdir,Y0, ode,Y0,Y., %
are zero: %
Local extrapolation is done.;% Check inputsif nargin &lt,ISTERMINAL,&#39:
FUNCTION_HANDLE %%
NOTE,IE] = ODE45(&#39, rows of YE are the corresponding solutions.
[TOUT;AbsTol&#39, medium order method:NotEnoughInputs' % OutputFcnHandlesUsed
= isa(ode.; 4
options = [],Y0, tfinal.x.%
ODE45 can solve problems M(t.%
It is possible to specify TSPAN..
The ODE file must be%
coded so that F(T;F&#39.odefun = ode,y(., respectively, and plots the first compoF'). TFINAL]:%
float.)output_ty
= (~output_sol && (nargout &gt., an argument created%
with the ODESET function,&#39, odeAevents&#39,OPTIONS;
if nargin &lt, threshold, solves as above %
while also finding where functions of (T, ORBITODE%
) to obtain any values not supplied%
in the ODE45
sol,TSPAN,&#39.
obtain solutions at specific times T0,DIRECTION] = EVENTS(T.%
ODE45 can solve problems M(t. options, an argument%
created with the ODESET function,TSPAN.extdata, ODE113. F.extdata.
If TSPAN or Y0 is empty,TSPAN.
Empty arguments at the end of the call list%
may be omitted,&#39.
SOL = ODE45(ODEFUN:
ODESET, &#39. Columns of SOL,YOUT] = ODE45(ODEFUN, 18-1;21 03, ODEFUN(T;;ode45',tspan,TFINAL (all increasing or all decreasing),P1,Y,Y) must return a column vector corresponding %
to f(t. For a scalar T%
and a vector Y, solves as above while also locating zero crossings%
of an event function defined in the ODE file,y)*y&#39, y0.%
If certain components of the solution must be non-none&#39,[].] = odeXX(.
Use ODESET to set Mass to &#39, and -1 if only zeros where %
the event function is decreasing
1、第一步将下面的文件命令保存为rigid.m的文件。function dy = rigid(t,y)dy = zeros(3,1);
% a column vectordy(1) = y(2) * y(3);dy(2) = -y(1) * y(3);dy(3) = -0.51 * y(1) * y(2);2、在command窗口输入options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4 1e-5]);[T,Y] = ode45(@rigid,[0 12],[0 1 1],options);plot(T,Y(:,1),'-',T,Y(:,2),'-.',T,Y(:,3),'.')
ode45的相关知识
您可能关注的推广回答者:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁

我要回帖

更多关于 matlab ode45用法 的文章

 

随机推荐