matlab ode45 函数传自定义参数用法及定步长ode5解算函数
来源:互联网 发布:晨曦预算软件视频教程 编辑:程序博客网 时间:2024/05/16 12:33
要用的时候总是忘记,这回给把它写在这里!
%%程序1
arg1 = 2;
arg2 = 1;
[T,Y] = ode45('vdp1000',[0 10],[2 0], [], arg1, arg2);
plot(T,Y(:,1),'-o');
%%程序2
function dy = vdp1000(t, y, flag, arg1, arg2)
dy = zeros(2,1);
dy(1) = y(2);
dy(2) = arg1*(arg2 - y(1)^2)*y(2) - y(1);
%%ode5
function Y = ode5(odefun,tspan,y0,varargin)
%ODE5 Solve differential equations with a non-adaptive method of order 5.
% Y = ODE5(ODEFUN,TSPAN,Y0) with TSPAN = [T1, T2, T3, ... TN] integrates
% the system of differential equations y' = f(t,y) by stepping from T0 to
% T1 to TN. Function ODEFUN(T,Y) must return f(t,y) in a column vector.
% The vector Y0 is the initial conditions at T0. Each row in the solution
% array Y corresponds to a time specified in TSPAN.
%
% Y = ODE5(ODEFUN,TSPAN,Y0,P1,P2...) passes the additional parameters
% P1,P2... to the derivative function as ODEFUN(T,Y,P1,P2...).
% This is a non-adaptive solver. The step sequence is determined by TSPAN
% but the derivative function ODEFUN is evaluated multiple times per step.
% The solver implements the Dormand-Prince method of order 5 in a general
% framework of explicit Runge-Kutta methods.
%
% Example
% tspan = 0:0.1:20;
% y = ode5(@vdp1,tspan,[2 0]);
% plot(tspan,y(:,1));
% solves the system y' = vdp1(t,y) with a constant step size of 0.1,
% and plots the first component of the solution.
if ~isnumeric(tspan)
end
if ~isnumeric(y0)
end
h = diff(tspan);
if any(sign(h(1))*h <= 0)
end
try
catch
end
y0 = y0(:); % Make a column vector.
if ~isequal(size(y0),size(f0))
end
neq = length(y0);
N = length(tspan);
Y = zeros(neq,N);
% Method coefficients -- Butcher's tableau
%
% C | A
% --+---
% | B
C = [1/5; 3/10; 4/5; 8/9; 1];
A = [ 1/5, 0, 0, 0, 0
3/40, 9/40, 0, 0, 0
44/45 -56/15, 32/9, 0, 0
19372/6561, -25360/2187, 64448/6561, -212/729, 0
9017/3168, -355/33, 46732/5247, 49/176, -5103/18656];
B = [35/384, 0, 500/1113, 125/192, -2187/6784, 11/84];
% More convenient storage
A = A.';
B = B(:);
nstages = length(B);
F = zeros(neq,nstages);
Y(:,1) = y0;
for i = 2:N
end
Y = Y.';
- matlab ode45 函数传自定义参数用法及定步长ode5解算函数
- matlab ode45 函数传自定义参数用法及定步长ode45结算函数
- MATLAB求解常微分方程:ode45函数与dsolve函数
- Matlab ode45 解微分方程
- Python自定义函数及函数参数
- MATLAB自定义函数及局部变量
- matlab 中 mvnrnd 函数用法及举例
- MATLAB save 函数用法及实例
- matlab std函数 用法及实例
- sort函数的用法,自定义comp参数。
- shell自定义函数及参数调用解析
- Matlab 函数参数汇总
- linux unset命令参数及用法详解--linux删除自定义变量或函数
- MATLAB自定义函数
- Matlab 自定义函数
- MATLAB--自定义函数
- Matlab 自定义函数
- Matlab 自定义函数拟合
- VC 注册表操作
- 开始学android
- 关于对Floyd算法的思索
- linux下的tar打包命令示例及详解
- windows8.1网络受限
- matlab ode45 函数传自定义参数用法及定步长ode5解算函数
- 对大学专业知识的期望跟目标
- android JNI NDK
- poj 1463 Strategic game(树形DP)
- vmlinuz、zImage和uImage的区别
- HMTL DOM结构
- WP8之Socket ——作为服务端接收消息
- 端口 port CMOS RAM
- mysql 语句大全