Problem in using ddesd for a simple DDE with one dependent variable and two delay terms.

조회 수: 4 (최근 30일)
Let's say we have only one independent variable t and one dependent variable x. Then consider the following DDE equation
dx/dt = t*x(t-cos(t)) + t^2 * x(t-2) + t^3 ; t >= 0
and with the history
I guess I have to use ddesd as one of my term delays is not a constant delay, i.e. t-cos(t).
Reading the help page of ddesd (https://uk.mathworks.com/help/matlab/ref/ddesd.html) didn't make it clear for me how to do it. Here is my attempt.
sol = ddesd( @dde_equation, @delay, @history, [ 0, 1 ] );
t = sol.x;
x = sol.y;
plot(t, x);
xlabel('t');
ylabel('x(t)');
title('Solution of Delay Differential Equation');
% local functions
function dxdt = ddefun( t, x, Z )
dxdt = t * Z( 1, 1 ) + ( t ^ 2 ) * Z( 1, 2 ) + t ^ 3;
end
function d = delay( t )
d = [ delay1( t ); delay2( t ) ];
end
function d1 = delay1( t )
d1 = t - cos( t );
end
function d2 = delay2( t )
d2 = t - 2;
end
function v = history( t )
v = sin( t );
end
But I get the following error message
Error using Matlab_20230517_DDE_1>delay
Too many input arguments.
Error in ddesd>lagvals (line 549)
d = delays(tnow,ynow);
Error in ddesd (line 146)
Z0 = lagvals(t0,y0,delays,history,t0,y0,[]);
Error in Matlab_20230517_DDE_1 (line 1)
sol = ddesd( @dde_equation, @delay, @history, [ 0, 1 ] );
I would appreciate if someone let me know what is my mistake and how to solve the above DDE using Matlab. I found help pages and examples of DDE in Matlab help confusing and not really well explained.

채택된 답변

Torsten
Torsten 2023년 5월 17일
sol = ddesd( @ddefun, @delay, @history, [ 0, 1 ] );
t = sol.x;
x = sol.y;
plot(t, x);
xlabel('t');
ylabel('x(t)');
title('Solution of Delay Differential Equation');
% local functions
function dxdt = ddefun( t, x, Z )
dxdt = t * Z( 1, 1 ) + ( t ^ 2 ) * Z( 1, 2 ) + t ^ 3;
end
function d = delay( t, x )
d = [ delay1( t ); delay2( t ) ];
end
function d1 = delay1( t )
d1 = t - cos( t );
end
function d2 = delay2( t )
d2 = t - 2;
end
function v = history( t )
v = sin( t );
end
  댓글 수: 2
Amirhossein Sadeghi Manesh
Amirhossein Sadeghi Manesh 2023년 5월 17일
@Torsten Thanks. Just to make sure that I understood right. I had one typo (dde_equation --> ddefun) and the other problem is that the delay function MUST have "x" as argument as well for the sake of ddesd. Am I right?
Torsten
Torsten 2023년 5월 17일
편집: Torsten 2023년 5월 17일
Yes. Or you have to modify the list of input arguments to "delay":
sol = ddesd( @ddefun, @(t,x)delay(t), @history, [ 0, 1 ] );
and leave the function "delay" as in your posted code.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Delay Differential Equations에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by