how can i stay 7t longer in my code

2 views (last 30 days)
조현 김
조현 김 on 28 Jun 2020
Answered: Steven Lord on 28 Jun 2020
[t,y]=ode45(@seirl,[0,300],[1,0,0.0014,0,0])
plot(t,y)
legend('S','E','I','R','l')
a=0.015;
b=0.6;
c=0.7;
e=0.2;
dydt=zeros(4,1);
dydt(1)=-a*y(1)*y(2);
dydt(2)=a*y(1)*y(2)-b*y(2)
dydt(3)=b*y(2)-c*y(3)
dydt(4)=c*y(3)
end
ive wrote those code to make SEIR model. But at the code I wrote, there are no incubation time,,, I want to make delay for 7t when moving dydt(2) to dydt(3) (when code goes dydt(2) to dydt(3), stay 7t to move on.) please help me :(

Answers (1)

Steven Lord
Steven Lord on 28 Jun 2020
If your equations depend not just on the value of the solution at the current time but also the value of the solution at a previous time, you don't have a system of ordinary differential equations. Instead use a delay differential equation solver like dde23 or ddesd.

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!