代码:
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.06,8.77,15.65,23.,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));
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,[800 1],t,x);
h=lsqcurvefit(f,[800 1],t,c);
i=lsqcurvefit(f,[800 1],t,d);
k=lsqcurvefit(f,[800 1],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)
subplot(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('原始数据','指数增长模型','阻滞增长模型',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,134.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.01,174.05,200.95]';
e=[0.54,1.18,1.98,5.06,8.77,15.65,23.,36.63,37.17,53.98,73.16,123.31,159.78]';
st_ = [500 30 0.2 ];
ft_ = fittype('a0/(1+b0*exp(-k0*(x-1)))',...
'dependent',{'y'},'independent',{'x'},...
'coefficients',{'a0', 'b0','k0'});
cf_ = fit(x,y,ft_,'Startpoint',st_)
plot(cf_,'fit',0.95);hold on,plot(x,y,'ro')
f1t_ = fittype('a1/(1+b1*exp(-k1*(x-1)))',...
'dependent',{'b'},'independent',{'x'},...
'coefficients',{'a1', 'b1','k1'});
c1f_ = fit(x,b,f1t_,'Startpoint',st_)
plot(c1f_,'fit',0.95);hold on,plot(x,b,'g*')
f2t_ = fittype('a2/(1+b2*exp(-k2*(x-1)))',...
'dependent',{'c'},'independent',{'x'},...
'coefficients',{'a2', 'b2','k2'});
c2f_ = fit(x,c,f2t_,'Startpoint',st_)
plot(c2f_,'fit',0.95);hold on,plot(x,c,'b+')
f3t_ = fittype('a3/(1+b3*exp(-k3*(x-1)))',...
'dependent',{'d'},'independent',{'x'},...
'coefficients',{'a3', 'b3','k3'});
c3f_ = fit(x,d,f3t_,'Startpoint',st_)
plot(c3f_,'fit',0.95);hold on,plot(x,d,'*')
f4t_ = fittype('a4/(1+b4*exp(-k4*(x-1)))',...
'dependent',{'e'},'independent',{'x'},...
'coefficients',{'a4', 'b4','k4'});
c4f_ = fit(x,e,f4t_,'Startpoint',st_)
plot(c4f_,'fit',0.95);hold on,plot(x,e,'yo')下载本文