Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Using ODE23s

조회 수: 1 (최근 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