matlab求解時滯微分方程,dde23調用格式:
sol = dde23(ddefun,lags,history,tspan);
--ddefun函數句柄,求解微分方程y'=f(t,y(t),y(t-τ1),...,y(t-τk))
必須寫成下面形式:
dydt =ddefun(t,y,Z);
其中t對應當前時間t,y為列向量,近似於y(t);Z(:,j)近似於y(t-τj)
--lags為延遲時間,為正常數。
例:方程中包含y1(t-0.2)和y2(t-1),則可以表示為lags=[0.2,1]
--history t≤t0 時的狀態變量的值
--tspan 積分區間 t0 = tspan(1),tf =tspan(end)。
看下面例子:
假定系統狀態方程為dXdt =- Ax(t) - Bx(t-0.23)+Bx(t-0.56); A= [3,-1,-1,-1;-1,2,0,-1;-1,0,2,-1;-1,-1,-1,3];B=A;
程序如下:
(1) 編寫延遲函數
function dx = ddefun(t,y,Z)
A = [3,-1,-1,-1;-1,2,0,-1;-1,0,2,-1;-1,-1,-1,3]; tau1= Z(:,1); tau2= Z(:,2); dx=-A*y-A*tau1-A*tau2;
(1) 編寫主調函數
tau = [0.23,0.56];
y0 = [1,7,3,0];
sol = dde23(@ddefun, tau, y0, [0, 50]);
% plot the system states
plot(sol.x,sol.y);
*注意:該函數返回的sol中結構體sol.x和sol.y均為按行排列,與ode45等不同
如只顯示一組數據plot(sol.x,sol.y(1,:));