Matlab 曲线拟合 lsqcurvefit函数问题,老是运行有错,但自己手动拟合的曲线拟合性很好,求大神帮忙解决xdata = 0:1:24;ydata = [1,1.01573,1.031006579,1.045842764,1.059417803,1.071707049,... 1.083978095,1.09612949,1.107693
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/27 08:00:50
Matlab 曲线拟合 lsqcurvefit函数问题,老是运行有错,但自己手动拟合的曲线拟合性很好,求大神帮忙解决xdata = 0:1:24;ydata = [1,1.01573,1.031006579,1.045842764,1.059417803,1.071707049,... 1.083978095,1.09612949,1.107693
Matlab 曲线拟合 lsqcurvefit函数问题,老是运行有错,但自己手动拟合的曲线拟合性很好,求大神帮忙解决
xdata = 0:1:24;
ydata = [1,1.01573,1.031006579,1.045842764,1.059417803,1.071707049,...
1.083978095,1.09612949,1.107693656,1.119235824,1.130495336,...
1.140828063,1.150160037,1.15887825,1.166932454,1.174459168,...
1.181517668,1.188453177,1.195453166,1.201765158,1.207978284,...
1.214114814,1.220027553,1.225871485,1.23174341];
plot(xdata, ydata, '*');
hold on;
f = '1.308/(1+(1.308-1)*exp(-1*1.308*0.051*x))';ezplot(f,[0 60 1 1.32]);% 我自己拟合的曲线,拟合性很好
x0 = [1.308,0.051];
curvefun = @(x,xdata)x(1)/(1+(x(1)-1)*exp(-1*x(1)*x(2)*xdata)),'x','xdata';% 函数单独一个文件也一样,这样方便些.
x = lsqcurvefit(curvefun, x0, xdata, ydata); % 提示出错
y = curvefun(x, xdata);
Matlab 曲线拟合 lsqcurvefit函数问题,老是运行有错,但自己手动拟合的曲线拟合性很好,求大神帮忙解决xdata = 0:1:24;ydata = [1,1.01573,1.031006579,1.045842764,1.059417803,1.071707049,... 1.083978095,1.09612949,1.107693
把curvefun修改了下,拟合很好.
xdata = 0:1:24;
ydata = [1,1.01573,1.031006579,1.045842764,1.059417803,1.071707049,...
1.083978095,1.09612949,1.107693656,1.119235824,1.130495336,...
1.140828063,1.150160037,1.15887825,1.166932454,1.174459168,...
1.181517668,1.188453177,1.195453166,1.201765158,1.207978284,...
1.214114814,1.220027553,1.225871485,1.23174341];
plot(xdata, ydata, '*');
hold on;
f = '1.308/(1+(1.308-1)*exp(-1*1.308*0.051*x))';ezplot(f,[0 60 1 1.32]);% 我自己拟合的曲线,拟合性很好
x0 = [1.308,0.051];
curvefun = @(x,xdata)x(1)./(1+(x(1)-1)*exp(-1*x(1)*x(2)*xdata));% 函数单独一个文件也一样,这样方便些.
x = lsqcurvefit(curvefun, x0, xdata, ydata); % 提示出错
y = curvefun(x, xdata);
plot(xdata, ydata, '*',xdata,y)