matlab 我用的lsqcurvefit进行拟合,代码如下:x=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];y=[148 149 150 151 153 155 156 154 146 129 102 69 51 44 43 41 41 43 43 43];c0=[1 1 1 1];x=lsqcurvefit('feimi',c0,xdata,y);feimi文件的内
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/04 00:58:16
![matlab 我用的lsqcurvefit进行拟合,代码如下:x=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];y=[148 149 150 151 153 155 156 154 146 129 102 69 51 44 43 41 41 43 43 43];c0=[1 1 1 1];x=lsqcurvefit('feimi',c0,xdata,y);feimi文件的内](/uploads/image/z/9448999-7-9.jpg?t=matlab+%E6%88%91%E7%94%A8%E7%9A%84lsqcurvefit%E8%BF%9B%E8%A1%8C%E6%8B%9F%E5%90%88%2C%E4%BB%A3%E7%A0%81%E5%A6%82%E4%B8%8B%EF%BC%9Ax%3D%5B1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20%5D%3By%3D%5B148+149+150+151+153+155+156+154+146+129+102+69+51+44+43+41+41+43+43+43%5D%3Bc0%3D%5B1+1+1+1%5D%3Bx%3Dlsqcurvefit%28%27feimi%27%2Cc0%2Cxdata%2Cy%29%3Bfeimi%E6%96%87%E4%BB%B6%E7%9A%84%E5%86%85)
matlab 我用的lsqcurvefit进行拟合,代码如下:x=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];y=[148 149 150 151 153 155 156 154 146 129 102 69 51 44 43 41 41 43 43 43];c0=[1 1 1 1];x=lsqcurvefit('feimi',c0,xdata,y);feimi文件的内
matlab
我用的lsqcurvefit进行拟合,代码如下:x=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
];y=[148 149 150 151 153 155 156 154 146 129 102 69 51 44 43 41 41 43 43 43];c0=[1 1 1 1];
x=lsqcurvefit('feimi',c0,xdata,y);feimi文件的内容如下
function f = feimi(c,xdata)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
f=c(4)/(exp((xdata-c(2))/c(3))+1)+c(1);
% f=c(1)*xdata+c(2)*xdata*xdata+c(3)*xdata*xdata*xdata+c(4);
end
为啥有错误呢,应该怎么改呢
matlab 我用的lsqcurvefit进行拟合,代码如下:x=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];y=[148 149 150 151 153 155 156 154 146 129 102 69 51 44 43 41 41 43 43 43];c0=[1 1 1 1];x=lsqcurvefit('feimi',c0,xdata,y);feimi文件的内
可以这样改:
function f = feimi(x,xdata)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
f=x(4)./(exp((xdata-x(2))./x(3))+1)+x(1);
% f=c(1)*xdata+c(2)*xdata*xdata+c(3)*xdata*xdata*xdata+c(4);
end
上面保存为feimi.m,在命令行输入
xdata=1:20;
ydata=[148 149 150 151 153 155 156 154 146 129 102 69 51 44 43 41 41 43 43 43];
x0=[1 1 1 1];
[x fval]=lsqcurvefit('feimi',x0,xdata,ydata)
结果:
Optimization terminated:first-order optimality less than OPTIONS.TolFun,
and no negative/zero curvature detected in trust region model.
x =
144.8182 11.4118 -0.0146 -98.3737
fval =
3.1999e+003