资源描述:
《matlab指数增长和阻滞增长拟合代码.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、代码:t=1:13;x=[3.04,6.63,11.13,28.43,49.22,87.85,134.11,200.00,208.69,303.03,410.73,580.00,728.57];c=[0.40,0.97,2.31,4.45,7.63,10.11,19.86,33.44,38.03,75.07,112.08,152.39,226.55];d=[2.06,2.35,3.17,8.06,15.22,28.82,43.31,54.67,55.83,75.26,102.01,174.05,200.95];e=[0.54,1.18,1.98,5
2、.06,8.77,15.65,23.89,36.63,37.17,53.98,73.16,123.31,159.78];%指数增长模型y=log(x);cc=log(c);dd=log(d);ee=log(e);a=polyfit(t,y,1);h=polyfit(t,cc,1);i=polyfit(t,dd,1);k=polyfit(t,ee,1);r=a(1);r2=h(1);r3=i(1);r4=k(1);x0=exp(a(2));x1=x0*exp(r*t);c0=exp(h(2));c1=c0*exp(r2*t);d0=exp(i(2))
3、;d1=d0*exp(r3*t);e0=exp(k(2));e1=e0*exp(r4*t);%阻滞增长模型f=@(a,t)a(1)./(1+(a(1)/x(1)-1)*exp(-a(2)*(t-t(1))));f=@(h,t)h(1)./(1+(h(1)/c(1)-1)*exp(-h(2)*(t-t(1))));f=@(i,t)i(1)./(1+(i(1)/d(1)-1)*exp(-i(2)*(t-t(1))));f=@(k,t)k(1)./(1+(k(1)/e(1)-1)*exp(-k(2)*(t-t(1))));a=lsqcurvefit(f,
4、[8001],t,x);h=lsqcurvefit(f,[8001],t,c);i=lsqcurvefit(f,[8001],t,d);k=lsqcurvefit(f,[8001],t,e);figure(1);subplot(2,1,1);plot(t,x,'o',t,x1,'r:.');x2=f(a,t);plot(t,x,'o',t,x1,'r:.',t,x2,'g*--')legend('原始数据','指数增长模型','阻滞增长模型',2)xlabel时间段ylabel公众号总量(万)title('资讯类');figure(1)subplo
5、t(2,1,2);plot(t,c,'o',t,c1,'r:.');c2=f(h,t);plot(t,c,'o',t,c1,'r:.',t,c2,'g*--')legend('原始数据','指数增长模型','阻滞增长模型',2)xlabel时间段ylabel公众号总量(万)title('生活类');figure(2)subplot(2,1,1);plot(t,d,'o',t,d1,'r:.');d2=f(i,t);plot(t,d,'o',t,d1,'r:.',t,d2,'g*--')legend('原始数据','指数增长模型','阻滞增长模型',
6、2)xlabel时间段ylabel公众号总量(万)title('娱乐类');figure(2)subplot(2,1,2);plot(t,e,'o',t,e1,'r:.');e2=f(k,t);plot(t,e,'o',t,e1,'r:.',t,e2,'g*--')legend('原始数据','指数增长模型','阻滞增长模型',2)xlabel时间段ylabel公众号总量(万)title('其他');参数资讯类生活类娱乐类其他类公众号总量程序代码:x=[1:2:26]';y=[3.04,6.63,11.13,28.43,49.22,87.85,13
7、4.11,200.00,208.69,303.03,410.73,580.00,728.57]';b=[2.04,2.14,3.68,10.86,17.60,33.27,47.05,75.26,77.66,88.72,123.48,130.25,141.29]';c=[0.40,0.97,2.31,4.45,7.63,10.11,19.86,33.44,38.03,75.07,112.08,152.39,226.55]';d=[2.06,2.35,3.17,8.06,15.22,28.82,43.31,54.67,55.83,75.26,102.0
8、1,174.05,200.95]';e=[0.54,1.18,1.98,5.06,8.77,15.65,23.89,36.