Question on DDE23

조회 수: 3 (최근 30일)
Fares
Fares 2022년 11월 1일
편집: Fares 2022년 12월 14일
I have been trying to solve a system of delay differential equations where the delay paramter is included in the 5th state variable that appears in the first two equations using DDE23. First, I coded the system as
function yp = ddefunc(~,y,Z)
yl1=Z(:,1);
yp = [a*y(1)-b*yl1(2); c*y(2) ];
end
Then, I solved the system using the dde23 solver as
a=0.05;
b=0.5;
c=0.5;
lags=1;
tspan=[0 10];
sol = dde23(@ddefunc,lags,[0.8; 0.2],tspan);
However, Matlab responed with this
Unrecognized function or variable 'a'.
I tried to use other codes available in the internet but I always ended up with the same error.
Please help!!

채택된 답변

Torsten
Torsten 2022년 11월 1일
편집: Torsten 2022년 11월 1일
lags=1;
tspan=[0 10];
sol = dde23(@ddefunc,lags,[0.8; 0.2],tspan);
plot(sol.x,sol.y(1,:))
function yp = ddefunc(~,y,Z)
a=0.05;
b=0.5;
c=0.5;
yl1=Z(:,1);
yp = [a*y(1)-b*yl1(2); c*y(2) ];
end
  댓글 수: 1
Fares
Fares 2022년 11월 1일
Dear Torsten,
Thank you so much for your help. I really appreicate it!!

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

추가 답변 (1개)

Steven Lord
Steven Lord 2022년 11월 1일
편집: Torsten 2022년 11월 1일
Nowhere in your ddefunc function do you define the variables a,b, etc. The fact that you've defined them in the script or function from which you call dde23 does not by default make them available inside ddefunc.
Use one of the techniques shown on this documentation page to make those values available to ddefunc, or if they're only used inside ddefunc move the lines of code that define those parameters into ddefunc.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by