大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE稳定放心使用
具有常时滞的 DDE
举例为如下方程
y 1 ′ ( t ) = y 1 ( t − 1 ) y 2 ′ ( t ) = y 1 ( t − 1 ) + y 2 ( t − 0.2 ) y 3 ′ ( t ) = y 2 ( t − 1 ) \begin{aligned} y_1′(t) &= y_1(t-1) \\ y_2′(t) &= y_1(t-1) + y_2(t-0.2) \\ y_3′(t) &= y_2(t-1) \\ \end{aligned} y1′(t)y2′(t)y3′(t)=y1(t−1)=y1(t−1)+y2(t−0.2)=y2(t−1)
编写时滞代码
%% 测试求解常时滞微分方程
% Author: Zhao-Jichao
% Date: 2021-07-05
clear
clc
%% Define Time-Delay
lags = [1 0.2];
tspan = [0 5];
sol = dde23(@ddefun, lags, @history, tspan);
%% Draw Results
plot(sol.x,sol.y,'-o')
xlabel('Time t');
ylabel('Solution y');
legend('y_1','y_2','y_3','Location','NorthWest');
%% DDE Function
function dydt = ddefun(t,y,Z) % equation being solved
ylag1 = Z(:,1);
ylag2 = Z(:,2);
dydt = [ylag1(1);
ylag1(1)+ylag2(2);
y(2)];
end
%-------------------------------------------
function s = history(t) % history function for t <= 0
s = ones(3,1);
end
%-------------------------------------------
修改成自用的一阶系统微分方程
y 1 ′ = y 1 ( t − 0.1 ) y 2 ′ = y 2 ( t − 0.5 ) \begin{aligned} y_1’&=y_1(t-0.1) \\ y_2’&=y_2(t-0.5) \\ \end{aligned} y1′y2′=y1(t−0.1)=y2(t−0.5)
写成了两个并列的形式,方便对比最终的效果。
代码如下
%% 测试求解常时滞微分方程
% Author: Zhao-Jichao
% Date: 2021-07-05
clear
clc
%% Define Time-Delay
lags = [0.1 0.5];
tspan = [0 5];
sol = dde23(@ddefun, lags, @history, tspan);
%% Draw Results
plot(sol.x,sol.y,'-o')
xlabel('Time t');
ylabel('Solution y');
legend('y_1','y_2','y_3','Location','NorthWest');
%% DDE Function
function dydt = ddefun(t,y,Z) % equation being solved
ylag1 = Z(:,1);
ylag2 = Z(:,2);
dydt = [-ylag1(2);
-ylag2(2)];
end
%-------------------------------------------
function s = history(t) % history function for t <= 0
s = ones(2,1);
end
%-------------------------------------------
再改一个二阶的
方程为:
y 1 ′ = y 2 ( t − 0.1 ) y 2 ′ = − 2 y 3 ′ = y 4 ( t − 0.5 ) y 4 ′ = − 2 \begin{aligned} y_1′ &= y_2(t-0.1) \\ y_2′ &= -2 \\ y_3′ &= y_4(t-0.5) \\ y_4′ &= -2 \\ \end{aligned} y1′y2′y3′y4′=y2(t−0.1)=−2=y4(t−0.5)=−2
%% 测试求解常时滞微分方程
% Author: Zhao-Jichao
% Date: 2021-07-05
clear
clc
%% Define Time-Delay
lags = [0.1 0.5];
tspan = [0 3];
sol = dde23(@ddefun, lags, @history, tspan);
%% Draw Results
plot(sol.x,sol.y)
xlabel('Time t');
ylabel('Solution y');
legend('y_1','y_2','y_3','y_4','Location','NorthWest');
%% DDE Function
function dydt = ddefun(t,y,Z) % equation being solved
ylag1 = Z(:,1);
ylag2 = Z(:,2);
dydt = [ylag1(2);
-2;
ylag2(4);
-2;];
end
%-------------------------------------------
function s = history(t) % history function for t <= 0
s = ones(4,1);
end
%-------------------------------------------
Ref: 时滞微分方程 — 示例
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/188839.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...