传染病模型SI、SIS、SIR(10页).doc
-SI模型利用MATLAB求解传染病模型中的SI模型的解析解:程序中a即,y即i>> y=dsolve('Dy=a*(y-y2)','y(0)=y0')y =1/(1-exp(-a*t)*(-1+y0)/y0)画图:SI模型的it曲线设=1, i(0)=0.1>> y=dsolve('Dy=y-y2','y(0)=0.1') y =1/(1+9*exp(-t)>> x=0:0.01:13;y=1./(1+9.*exp(-x);>> plot(x,y)title('SI模型的it曲线');xlabel('t');ylabel('i');axis(0 13 0 1.1);画图:SI模型的di/dti曲线程序中x即i,y即di/dt,=1>> x=0:0.01:1;y=x-x.*x;>> plot(x,y)title('SI模型的di/dti曲线');xlabel('i');ylabel('di/dt');>>SIS模型利用MATLAB求解传染病模型中的SIS模型的解析解:程序中a即,b即,y即i>> y=dsolve('Dy=a*(y-y2)-b*y','y(0)=y0') y = (a-b)/(a-exp(-(a-b)*t)*(-a+b+y0*a)/y0/(a-b)*a+exp(-(a-b)*t)*(-a+b+y0*a)/y0/(a-b)*b)画图:SIS模型的di/dti曲线(>1)程序中x即i,y即di/dt,=1,=0.3>> x=0:0.01:1;>> y=0.7.*x-x.2;>> plot(x,y)title('SIS模型的di/dti曲线');xlabel('i');ylabel('di/dt');>>画图:SIS模型的it曲线(>1)设=1,=0.3,i(0)=0.02>> y=dsolve('Dy=0.7*y-y2','y(0)=0.02') y = 7/(10+340*exp(-7/10*t) >> x=0:1:16;>> y=7./(10+340.*exp(-7./10.*x);>> plot(x,y)title('SIS模型的it曲线');xlabel('t');ylabel('i');>>画图:SIS模型的di/dti曲线(1)程序中x即i,y即di/dt,=0.5,=0.6>> x=0:0.01:1;>> y=-0.5.*x.2-0.1.*x;>> plot(x,y)title('SIS模型的di/dti曲线');xlabel('i');ylabel('di/dt');>>画图:SIS模型的it曲线(1)设=0.5,=0.6,i(0)=0.02>> y=dsolve('Dy=-0.5*y2-0.1*y','y(0)=0.02') y = 1/(-5+55*exp(1/10*t) >> x=0:1:40;>> y=1./(-5+55.*exp(1./10.*x);>> plot(x,y)title('SIS模型的it曲线');xlabel('t');ylabel('i');>>SIR模型利用MATLAB求解传染病模型中的SIR模型的数值解:程序中a=1, b=0.3,i(0)=0.02,s(0)=0.98M文件中:function y=ill(t,x)a=1;b=0.3;y=a*x(1)*x(2)-b*x(1),-a*x(1)*x(2)'命令窗口中:>> t,x=ode45('ill',0:50,0.02,0.98);t,xans = 0 0.0200 0.9800 1.0000 0.0390 0.9525 2.0000 0.0732 0.9019 3.0000 0.1285 0.8169 4.0000 0.2033 0.6927 5.0000 0.2795 0.5438 6.0000 0.3312 0.3995 7.0000 0.3444 0.2839 8.0000 0.3247 0.2027 9.0000 0.2863 0.1493 10.0000 0.2418 0.1145 11.0000 0.1986 0.0917 12.0000 0.1599 0.0767 13.0000 0.1272 0.0665 14.0000 0.1004 0.0593 15.0000 0.0787 0.0543 16.0000 0.0614 0.0507 17.0000 0.0478 0.0480 18.0000 0.0371 0.0460 19.0000 0.0287 0.0445 20.0000 0.0223 0.0434 21.0000 0.0172 0.0426 22.0000 0.0133 0.0419 23.0000 0.0103 0.0415 24.0000 0.0079 0.0411 25.0000 0.0061 0.0408 26.0000 0.0047 0.0406 27.0000 0.0036 0.0404 28.0000 0.0028 0.0403 29.0000 0.0022 0.0402 30.0000 0.0017 0.0401 31.0000 0.0013 0.0400 32.0000 0.0010 0.0400 33.0000 0.0008 0.0400 34.0000 0.0006 0.0399 35.0000 0.0005 0.0399 36.0000 0.0004 0.0399 37.0000 0.0003 0.0399 38.0000 0.0002 0.0399 39.0000 0.0002 0.0399 40.0000 0.0001 0.0399 41.0000 0.0001 0.0399 42.0000 0.0001 0.0399 43.0000 0.0001 0.0399 44.0000 0.0000 0.0398 45.0000 0.0000 0.0398 46.0000 0.0000 0.0398 47.0000 0.0000 0.0398 48.0000 0.0000 0.0398 49.0000 0.0000 0.0398 50.0000 0.0000 0.0398>> plot(t,x(:,1),t,x(:,2),grid,pausei(t),s(t)图形如下:>> plot(x(:,2),x(:,1),grid,pauseis图形(相轨线)如下:画图:SIR模型的相轨线程序中y即i, x即s, =1,=0.3 s(0)=0.32; s(0)=0.58; s(0)=0.73; s(0)=0.85>> x=0:0.01:1;>> y=1-x;>> y1=1-x+0.3.*(log(x)-log(0.32);>> y2=1-x+0.3.*(log(x)-log(0.58);>> y3=1-x+0.3.*(log(x)-log(0.73);>> y4=1-x+0.3.*(log(x)-log(0.85);>> plot(x,y,x,y1,x,y2,x,y3,x,y4)axis(0 1 0 1);title('SIR模型的is曲线');xlabel('s');ylabel('i');-第 10 页-