MATLAB指数函数如何表达?yyy=339*(1+p)^xx.;这一步过不去x=1:20;y=[339,482,588,693,774,877,988,1114,1199,1347,1440,1553,1636,1741,1803,1897,1960,2049,2136,2177,];for i=1:length(y)-1yy(i)=(y(i+1)/y(i))-1;endp=polyfit(x(2:end),y(2:end),1);xxx

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/15 02:03:53
MATLAB指数函数如何表达?yyy=339*(1+p)^xx.;这一步过不去x=1:20;y=[339,482,588,693,774,877,988,1114,1199,1347,1440,155

MATLAB指数函数如何表达?yyy=339*(1+p)^xx.;这一步过不去x=1:20;y=[339,482,588,693,774,877,988,1114,1199,1347,1440,1553,1636,1741,1803,1897,1960,2049,2136,2177,];for i=1:length(y)-1yy(i)=(y(i+1)/y(i))-1;endp=polyfit(x(2:end),y(2:end),1);xxx
MATLAB指数函数如何表达?
yyy=339*(1+p)^xx.;这一步过不去
x=1:20;
y=[339,482,588,693,774,877,988,1114,1199,1347,1440,1553,1636,1741,1803,1897,1960,2049,2136,2177,];
for i=1:length(y)-1
yy(i)=(y(i+1)/y(i))-1;
end
p=polyfit(x(2:end),y(2:end),1);
xxx=1:65;
yyy=339*(1+p)^xx.;
w=1:65;
z=[339,482,588,693,774,877,988,1114,1199,1347,1440,1553,1636,1741,1803,1897,1960,2049,2136,2177,2227,2265,2304,2347,2370,2388,2405,2420,2434,2437,2444,2444,2456,2465,2490,2499,2504,2512,2514,2517,2520,2521,2522,2522,2522,2522,2522,2522,2523,2522,2522,2522,2523,2523,2522,2522,2522,2521,2521,2521,2521,2521,2521,2521,2521];
plot(w,z,'x',xxx,yyy);
legend('已确诊病例累计');
xlabel('天数');ylabel('人数');
title('利用前20天数据作出的logistic拟合')
附上全代码:

MATLAB指数函数如何表达?yyy=339*(1+p)^xx.;这一步过不去x=1:20;y=[339,482,588,693,774,877,988,1114,1199,1347,1440,1553,1636,1741,1803,1897,1960,2049,2136,2177,];for i=1:length(y)-1yy(i)=(y(i+1)/y(i))-1;endp=polyfit(x(2:end),y(2:end),1);xxx
x=1:20;
y=[339,482,588,693,774,877,988,1114,1199,1347,1440,1553,1636,1741,1803,1897,1960,2049,2136,2177,];
p=polyfit(x,y,2)
xxx=1:65;
yyy=polyval(p,xxx);
w=1:65;
z=[339,482,588,693,774,877,988,1114,1199,1347,1440,1553,1636,1741,1803,1897,1960,2049,2136,2177,2227,2265,2304,2347,2370,2388,2405,2420,2434,2437,2444,2444,2456,2465,2490,2499,2504,2512,2514,2517,2520,2521,2522,2522,2522,2522,2522,2522,2523,2522,2522,2522,2523,2523,2522,2522,2522,2521,2521,2521,2521,2521,2521,2521,2521];
%k=exp(p(2)+p(1)*xxx)
plot(w,z,'x',xxx,yyy);
legend('已确诊病例累计');
xlabel('天数');ylabel('人数');
title('利用前20天数据作出的logistic拟合')
拟合的不是很理想,不过还可以,思想就是这样!