主要内容

dde23

求解带有固定时滞的时滞微分方程 (DDE)

    说明

    sol = dde23(ddefun,delays,history,tspan)(其中 tspan = [t0 tf])在 tspan 指定的区间上对时滞微分方程组 y(t)=f(t,y(t),y(tτ1),...,y(tτk)) 进行积分,其中 τ1,...,τk 是由 delays 指定的恒定正时滞。

    示例

    sol = dde23(ddefun,delays,history,tspan,options) 使用由 options(它是使用 ddeset 函数创建的结构体)定义的积分设置。例如,使用 AbsTolRelTol 选项指定绝对误差容限和相对误差容限,或者使用 Jumps 选项提供不连续点的位置。

    示例

    示例

    全部折叠

    求解时滞微分方程组

    y1(t)=-2y1(t-2)+y2(t)y2(t)=y1(t)-2y2(t-1),

    其中 y1(t) 具有常历史解 y1(t)=0.1y2(t) 具有常历史解 y2(t)=0.5 (t0)。应用于 y1(t) 的时滞是 2,应用于 y2(t) 的时滞是 1。

    将 DDE 方程组定义为一个名为 ddefun 的局部函数。

    function dydt = ddefun(t,y,Z)
    ydelay1 = Z(:,1);
    ydelay2 = Z(:,2);
    dydt = [-2*ydelay1(1) + y(2);
            y(1) - 2*ydelay2(2)];
    end

    指定积分区间为 [0 10],时滞为向量 [2; 1],历史解为向量 [0.1; 0.5]。使用 dde23 解算 DDE。

    tspan = [0 10];
    delays = [2; 1];
    history = [0.1; 0.5];
    sol = dde23(@ddefun,delays,history,tspan);

    绘制结果。

    plot(sol.x,sol.y)

    Figure contains an axes object. The axes object contains 2 objects of type line.

    求解 DDE

    y(t)=-2y(t-1)(1+y(t)),

    其中,当 t0 时,y(t)=t

    将 DDE 定义为名为 ddefun 的局部函数。

    function dydt = ddefun(t,y,ydelay)          
    dydt = -2*ydelay*(1+y);
    end

    将历史解定义为名为 history 的局部函数。

    function h = history(t)
    h = t;
    end

    通过使用 ddeset 函数指定积分器 options 结构体的 Events 字段,在不终止积分的情况下找到方程的零点。

    function [position,isterminal,direction] = zeroEventsFcn(t,y,ydelay)
    position = y(1);
    isterminal = 0;
    direction = 0;
    end
    
    opts = ddeset(Events=@zeroEventsFcn);

    指定积分区间为 [0 10],时滞为 1。然后使用 dde23 求解 DDE。

    tspan = [0 10];
    delays = 1;
    sol = dde23(@ddefun,delays,@history,tspan,opts);

    绘制结果和过零点的位置。

    plot(sol.x,sol.y,sol.xe,sol.ye,"o")

    Figure contains an axes object. The axes object contains 2 objects of type line. One or more of the lines displays its values using only markers

    输入参数

    全部折叠

    要求解的时滞微分方程组,指定为函数句柄。

    标量 t 和列向量 y 的函数 dydt = ddefun(t,y,Z) 必须返回与 y(t)=f(t,y(t),y(tτ1),...,y(tτk)) 对应的数据类型为 singledouble 的列向量 dydt。标量 t 对应于当前 t,列向量 y 逼近 y(t)Z(:,j) 逼近 y(t-τj) (τj = delays(j))。

    示例: @myFcn

    数据类型: function_handle

    时滞,指定为正向量。delays 向量表示固定正时滞 τ1,...,τk

    示例: [1 0.2]

    数据类型: single | double

    tt0 条件下的历史解,指定为以下值之一:

    • 函数句柄,该函数句柄使得 y = history(t) 对于标量 t 返回列向量

    • 常向量 y(t)

    • 来自之前积分的解结构体 sol(如果当前 dde23 函数调用继续该积分)

    示例: @ddeHist

    示例: [1; 0.4; 0.2]

    数据类型: function_handle | single | double | struct

    积分区间,指定为表示初始和最终时间的二元素向量 [t0 tf]。要获得在 t0tf 之间的特定时间的解,请使用 deval

    示例: [1 10]

    数据类型: single | double

    积分器选项,指定为结构体数组。使用 ddeset 函数创建或修改 options 结构体。

    示例: options = ddeset(RelTol=1e-5,Stats="on") 指定相对误差容限为 1e-5,并启用求解器统计信息的显示。

    数据类型: struct

    输出参量

    全部折叠

    用于计算的解,以结构体数组形式返回。此结构体与 deval 函数一起使用,用于计算由 tspan 指定的区间内任何点的解。

    sol 结构体包括以下字段。

    结构体字段描述

    sol.x

    dde23 选择的网格

    sol.y

    sol.x 中网格点处 y'(x) 的逼近

    sol.yp

    sol.x 中网格点处 y'(x) 的逼近

    sol.solver

    求解器名称 'dde23'

    此外,如果在 options 结构体中指定了 Events 选项并且检测到事件,则 sol 还包括下列字段。

    结构体字段描述

    sol.xe

    事件发生的点。sol.xe(end) 包含终止事件(如果有)的确切点。

    sol.ye

    对应于 sol.xe 中事件时间的解

    sol.ie

    Events 选项中指定的函数所返回的向量的索引。这些值指示求解器检测到的事件。

    算法

    dde23 跟踪不连续性并使用显式龙格-库塔 (2,3) 对和插值对 ode23 求积分。它通过迭代来采用超过时滞的步长。

    参考

    [1] Shampine, Lawrence F., and S. Thompson. "Solving DDEs in MATLAB." Applied Numerical Mathematics 37, no. 4 (June 2001): 441–458. https://doi.org/10.1016/S0168-9274(00)00055-6.

    [2] Kierzenka, Jacek. "Tutorial on Solving DDEs with DDE23." MATLAB Central File Exchange. Updated September 1, 2016. https://www.mathworks.com/matlabcentral/fileexchange/3899-tutorial-on-solving-ddes-with-dde23.

    [3] Willé, David R., and Christopher T. H. Baker. "DELSOL—a Numerical Code for the Solution of Systems of Delay-Differential Equations." Applied Numerical Mathematics 9, no. 3 (April 1992): 223–234. https://doi.org/10.1016/0168-9274(92)90017-8.

    版本历史记录

    在 R2006a 之前推出