用MATLAB拟合曲线并求函数
来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/04/28 00:52:45
用MATLAB拟合曲线并求函数
x=[0 0.1 0.2 0.4 0.6 0.8 1]
y=[7.53 7.04 6.2 4.8 3.57 3.03 2.54]
数据如下,已知尽量拟合成y=7.53-Aln(1+bx)的形式,我用MATLAB,一拟合就拟合失败,有没有什么软件能拟合出来
x=[0 0.1 0.2 0.4 0.6 0.8 1]
y=[7.53 7.04 6.2 4.8 3.57 3.03 2.54]
数据如下,已知尽量拟合成y=7.53-Aln(1+bx)的形式,我用MATLAB,一拟合就拟合失败,有没有什么软件能拟合出来
>> x=[0 0.1 0.2 0.4 0.6 0.8 1];y=[7.53 7.04 6.2 4.8 3.57 3.03 2.54];
fitType=fittype('7.53-a*log(1+b*x)','independent','x','coefficients',{'a','b'})
fit(x',y',fitType)
fitType =
General model: fitType(a,b,x) = 7.53-a*log(1+b*x)
Warning: Start point not provided, choosing random start point.
> In Warning>Warning.throw at 31
In fit>iFit at 320
In fit at 109
ans =
General model: ans(x) = 7.53-a*log(1+b*x)
Coefficients (with 95% confidence bounds):
a = 5.522 (0.9524, 10.09)
b = 1.555 (-0.2776, 3.388)
这样行不行?
再问: 可以的,请问我自己要怎么输才能出来图象
再答: 这是在cftool中自动生成的,你可以直接在cftool直接拟合,不用编程,命令窗口键入cftool,即可打开,具体用法请看help可改为以下程序x=[0 0.1 0.2 0.4 0.6 0.8 1];y=[7.53 7.04 6.2 4.8 3.57 3.03 2.54];fitType=fittype('7.53-a*log(1+b*x)','independent','x','coefficients',{'a','b'})fit_y=fit(x',y',fitType); plot(fit_y) hold onplot(x,y,'o')
fitType=fittype('7.53-a*log(1+b*x)','independent','x','coefficients',{'a','b'})
fit(x',y',fitType)
fitType =
General model: fitType(a,b,x) = 7.53-a*log(1+b*x)
Warning: Start point not provided, choosing random start point.
> In Warning>Warning.throw at 31
In fit>iFit at 320
In fit at 109
ans =
General model: ans(x) = 7.53-a*log(1+b*x)
Coefficients (with 95% confidence bounds):
a = 5.522 (0.9524, 10.09)
b = 1.555 (-0.2776, 3.388)
这样行不行?
再问: 可以的,请问我自己要怎么输才能出来图象
再答: 这是在cftool中自动生成的,你可以直接在cftool直接拟合,不用编程,命令窗口键入cftool,即可打开,具体用法请看help可改为以下程序x=[0 0.1 0.2 0.4 0.6 0.8 1];y=[7.53 7.04 6.2 4.8 3.57 3.03 2.54];fitType=fittype('7.53-a*log(1+b*x)','independent','x','coefficients',{'a','b'})fit_y=fit(x',y',fitType); plot(fit_y) hold onplot(x,y,'o')