时滞微分方程的matlab解法之二dde23---另外一些例子

时间:2021-03-14 06:47:29

1.考虑下面的时滞微分方程

时滞微分方程的matlab解法之二dde23---另外一些例子

用matlab编程绘出其图像

程序:

function test1
clear;
clc;
lags=[1]; tspan=[0,100];
sol=dde23(@ddefun,lags,@history,tspan); 
plot(sol.x,sol.y); 
title('ddefun');xlabel('t');ylabel('y'); 
legend('y_1','y_2','y_3','y_4',2); 

function dydt=ddefun(t,y,Z) 
ylag1=Z(:,1); 


dydt=[(-0.5)*y(1)-2*y(2)+ylag1(3) 
2*y(1)-0.5*y(2)+ylag1(4) 
(-0.5)*y(3)-0.5*y(4)+ylag1(1) 
0.5*y(3)-0.5*y(4)+ylag1(2)]; 

function S=history(t) 
S=ones(4,1); 

图像如下:

时滞微分方程的matlab解法之二dde23---另外一些例子

2.考虑下面非线性时延微分方程

时滞微分方程的matlab解法之二dde23---另外一些例子

用matlab编程绘制其解的图像

程序:

function test2
tau=2;
ddefun=@(t,x,z)1-x(1)*z(1,1)^3/(1+z(1,1)^3);
sol=dde23(ddefun,tau,0,[0 10]);
plot(sol.x,sol.y); 

图像如下: