Logistic模型:a/(1+(a/b-1)*exp(-k*t))
实现代码:
clc,clear all,close all
%Logistic模型用matlab求解
%时间是2000年到2010年
%数据是Q=[503.02 526.02 561.96 629.2 700.21 788.15 876.76 989.23 1058.23 1135.13 1330]
%要预测2015年的用水量。
t=[1:11];
Q=[503.02 526.02 561.96 629.2 700.21 788.15 876.76 989.23 1058.23 1135.13 1330];
func=inline('a(1)./(1+(a(1)/a(2)-1)*exp(-a(3).*t))','a','t');
b=[0.1576 0.9706 0.9572]
a=lsqcurvefit(func,b,t,Q);
Q1=func(a,t);
y=Q';y1=Q';
WZ=['Q=',num2str(a(1)),'/(1+(',num2str(a(1)),'/',num2str(a(2)),'-1)*','exp(-',num2str(a(3)),'*t)'];
figure
tt=2000:2010;
xx=min(t):1:max(t);
yy=func(a,xx);
plot(tt,Q,'rp'),hold on
plot(tt,yy,'*-'),xlabel('年份'),ylabel('用水量(万吨)'),hold off %,grid on
text(2000,1300,WZ,'FontSize',10);
t0=2015-2000+1;y0=func(a,t0);
text(2000,1200,['预测2015年的用水量:',num2str(max(y0)),'(万吨)'])
运行结果
预测2015年的用水量:1972万吨