Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Using ODE23s

5 ビュー (過去 30 日間)
SA
SA 2019 年 4 月 24 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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
%I=y1;
%S=y2;
%R=y3;
options = odeset('Events',@myEventsFcn);
[t,y,te,ye,ie] = ode23s(@challenge215,tRange,y0,options)
plot(t,mean(y(:,1)),'k')
hold on
plot(t,mean(y(:,2)),'b')
hold on
plot(t,mean(y(:,3)),'r')
xlabel('Days')
ylabel('Population')
xlim([-inf tfinal])
ylim([0 inf])
legend('Infected', 'Susceptible', 'Recovered')
title('Solution to Ordinary Differential Equation Model 4')
function dydt=challenge215(t,y)
k = 4;
tau = 0.8;
delta = 0.2;
y1=y(:,1);
y2=y(:,2);
y3=y(:,3);
[Atilde]=GetTheMatrix(11);
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];
end
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];
end
  1 件のコメント
Jan
Jan 2019 年 4 月 25 日
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?

回答 (0 件)

この質問は閉じられています。

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by