How to plot with various initial conditions?

Edited: I want to plot
using the model with different initial conditions(use whatever you like)
function dydt = model (t,y)
dydt = zeros (size(y));
Ah=0.000051;Av=0.071;b1=0.071;b2=0.091;g=0.0035;
d1=0.0000043;d2=0.04;e1=0.001;w=0.11;
Sh=y(1);
Ih=y(2);
Rh=y(3);
Sv=y(4);
Iv=y(5);
Nh = Sh+Ih+Rh;
%The model
dydt(1) = Ah - b1*Iv*Sh/Nh +w*Rh - d1*Sh;
dydt(2) = b1*Iv*Sh/Nh - (g + e1 + d1)*Ih;
dydt(3) = g*Ih - (w +d1)*Rh;
dydt(4) = Av - b2*Ih*Sv/Nh - d2*Sv;
dydt(5) = b2*Ih*Sv/Nh - d2*Iv;
% plot
tspan = [0 10000];
y0 = [3600 1000 100 9600 400];% Here is the initial condition
[t,y] = ode45(@model,tspan,y0);
plot(t,y(:,2),'r','Linewidth',1)
title('Plot of human population against time')
xlabel('Time(years)')
ylabel('Number of People')
legend('Infectious')
Regards,

댓글 수: 4

KSSV
KSSV 2017년 6월 9일
What and where are the initial conditions here in the code?
y0 = [3600 1000 100 9600 400];
is the initial condition. (I've added a comment right to it)
Torsten
Torsten 2017년 6월 9일
And what should be the result of the three lines of code below ?
Best wishes
Torsten.
KSSV
KSSV 2017년 6월 9일
Then what is this params1 ??

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

 채택된 답변

KSSV
KSSV 2017년 6월 9일

0 개 추천

tspan = [0 10000];
% initilai conditions
figure
hold on
for i = 1:5
% y0 = [3600 1000 100 9600 400];
y0 = rand(1,5)*100*i ;
[t,y] = ode45(@model,tspan,y0);
plot(t,y(:,2),'r','Linewidth',1)
end
title('Plot of human population against time')
xlabel('Time(years)')
ylabel('Number of People')
legend('Infectious')

댓글 수: 3

Thank you! But what if I want to use the following initials
y0 = [13413000 3350000 3343000 16500000 38000000];
y0 = [13400 3350 3000 165000 38000];
y0 = [1341300 436000 334300 1650000 3800000];
y0 = [1341300 55000 33430 1650000 3800000];
y0 = [13400 3200 2800 16500000 38000000];
y0 = [134000 43350 3000 165000 38000];
y0 = [15130 6000 4300 1650000 3800000];
y0 = [16000 5000 4000 1650000 3800000];
Init=[13413000 3350000 3343000 16500000 38000000
13400 3350 3000 165000 38000
1341300 436000 334300 1650000 3800000
1341300 55000 33430 1650000 3800000
13400 3200 2800 16500000 38000000
134000 43350 3000 165000 38000
15130 6000 4300 1650000 3800000
16000 5000 4000 1650000 3800000];
tspan = [0 10000];
% initilai conditions
figure
hold on
for i = 1:8
y0 = Init(i,:) ;
[t,y] = ode45(@model,tspan,y0);
plot(t,y(:,2),'r','Linewidth',1)
end
title('Plot of human population against time')
xlabel('Time(years)')
ylabel('Number of People')
legend('Infectious')
marya
marya 2017년 6월 9일
Thank You Very MUCH!!!

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

추가 답변 (0개)

카테고리

태그

질문:

2017년 6월 9일

댓글:

2017년 6월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by