clf,clear
I=@(k,t)(k(1)./((1+k(2)).^t)).^t; % R0=k(1),control parameter d = k(2)
load data3.txt; %data3.txt在附件中
tspan=data3(:,1);
Iexp=data3(:,2);
k0=[1.8,0.001];
ksim=nlinfit(tspan,Iexp,I,k0);
fprintf('\n\n使用函数nlinfit()估计得到的参数值为:\n')
fprintf('\t R0 = %.6e\n',ksim(1))
fprintf('\t d = %.6e\n',ksim(2))
sse = sum((Iexp-I(ksim,tspan)).^2)./sum(Iexp)
a=size(tspan,1);
Isim=zeros(a,2);
for i =1:a
Isim(i)=integral(@(t)I(t,ksim),0,tspan(i));
end
plot(tspan,Iexp,'ko',tspan,Isim(tspan),'r')
运行之后,出错了。。。。
Error using integralCalc/finalInputChecks (line 515)
Output of the function must be the same size as the input. If FUN is an array-valued
integrand, set the 'ArrayValued' option to true.