This question is closed. Reopen it to edit or answer.
1 view (last 30 days)
Show older comments
SA on 24 Apr 2019
Closed: MATLAB Answer Bot on 20 Aug 2021
In the code below, y1, y2 and y3 are functions of three variabes t, x and y. y1(0,x,y) = 1 and y2(0,x,y)=y3(0,x,y)=0 are the initial conditions. But there is an exception; at y1(0,0.5,0.5) = y2(0,0.5,0.5)=0.5
How do I incorproate this in my code?
%Solving and plotting Model 4
tfinal = 10; %will vary
tRange = [0,tfinal];
y0=[1; 0; 0];%the initial conditions for I,S and R respectively
options = odeset('Events',@myEventsFcn);
[t,y,te,ye,ie] = ode23s(@challenge215,tRange,y0,options)
legend('Infected', 'Susceptible', 'Recovered')
title('Solution to Ordinary Differential Equation Model 4')
k = 4;
tau = 0.8;
delta = 0.2;
dydt = [tau*y1.*y2-(1/k)*y1+delta*((1/(0.1^2))*Atilde*y1).*y2;-tau*y1.*y2-delta*((1/(0.1^2))*Atilde*y1).*y2;(1/k)*y1];
function [position,isterminal,direction] = myEventsFcn(t,y)
position = [y1-(10^-5); y2-(10^-5)]; % the function I is unknown
isterminal = [1; 1]; %terminate when I(t) drops below 10^-5
direction = [0; 0];
Jan on 25 Apr 2019
What does "y1(0,x,y) = 1" mean? What is x and y here? "% the function I is unknown"? Which function I? If you have "y1(0,0.5,0.5) = y2(0,0.5,0.5)=0.5", it is not an initial value problem anymore, but a boundary value problem, isn't it?
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!