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
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.
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Delay Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!