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函数问题,老是运行有错,但自己手动拟合的曲线拟合性很好,求大神帮忙解决
答案:2 悬赏:40 手机版
解决时间 2021-01-31 14:45
- 提问者网友:谁的错
- 2021-01-30 18:19
最佳答案
- 五星知识达人网友:鱼芗
- 2021-01-30 19:19
把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)
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)
全部回答
- 1楼网友:渊鱼
- 2021-01-30 20:19
我暂时保留我的看法!
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯