matlab定步长ode,[转载]matlab ode45 函数传自定义参数用法及定步长ode

本文介绍了如何在 MATLAB 中使用 ode45 函数进行定步长的微分方程求解,并给出了示例程序1和自定义ode5函数的实现。ode5函数采用Dormand-Prince五阶方法,允许用户指定固定的步长并传递额外参数给微分方程函数。
摘要由CSDN通过智能技术生成

要用的时候总是忘记,这回给把它写在这里!

%%程序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); %

a column vector

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值