麻烦matlab高手用lsqcurvefit函数帮我拟合一组数据.y=[0.925,0.881,0.8604,0.8604,0.8409,0.8409,0.8409,0.8222,0.8222,0.8222,0.8044,0.8044,0.8044,0.8044,0.7872,0.7872,0.7872,0.7872,0.7708,0.7708,0.7708,0.7708,0.7708,0.7551,0.7255,0.7115,0.67
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 01:51:24
麻烦matlab高手用lsqcurvefit函数帮我拟合一组数据.y=[0.925,0.881,0.8604,0.8604,0.8409,0.8409,0.8409,0.8222,0.8222,0.8222,0.8044,0.8044,0.8044,0.8044,0.7872,0.7872,0.7872,0.7872,0.7708,0.7708,0.7708,0.7708,0.7708,0.7551,0.7255,0.7115,0.67
麻烦matlab高手用lsqcurvefit函数帮我拟合一组数据.
y=[0.925,0.881,0.8604,0.8604,0.8409,0.8409,0.8409,0.8222,0.8222,0.8222,0.8044,
0.8044,0.8044,0.8044,0.7872,0.7872,0.7872,0.7872,0.7708,0.7708,0.7708,0.7708,
0.7708,0.7551,0.7255,0.7115,0.6727,0.6599,0.6491,0.6379,0.6271,0.6271,0.6167,
0.6167,0.6066,0.6066,0.6066,0.5968,0.5968,0.5968,0.5873,0.5873,0.5873,0.5873]
x=[0.0833,0.1667,0.25,0.3333,0.4167,0.5,0.5833,0.6667,0.75,0.8333,0.9167,1,1.0833
,1.1667,1.25,1.3333,1.4167,1.5,1.5833,1.6667,1.75,1.8333,1.9167,2,6,9,22,34,46,58,70,82,94,106,118,130,142,154,166,178,190,202,214,226].想用matlab里的lsqcurvefit拟合出下面这个函数,y=1/a+x/b+(1/c)*[1-exp(-c*x/d)].a,b,c,d要求的大于0的.就这些条件了.麻烦哪位会的同学,帮我解决下,-哪里看不清的可以说下.
麻烦matlab高手用lsqcurvefit函数帮我拟合一组数据.y=[0.925,0.881,0.8604,0.8604,0.8409,0.8409,0.8409,0.8222,0.8222,0.8222,0.8044,0.8044,0.8044,0.8044,0.7872,0.7872,0.7872,0.7872,0.7708,0.7708,0.7708,0.7708,0.7708,0.7551,0.7255,0.7115,0.67
我做了一下发现误差比较大,是不是我给的初值有问题,还是给的数据有问题,你可以参考下
function f=curvefun1(x,xdata)
% y=1/a+x/b+(1/c)*[1-exp(-c*x/d)]
f=1/x(1)+xdata/x(2)+(1/x(3))*(1-exp(-x(3)*xdata/x(4)));
运行:
clear;clc;
xdata=[0.0833,0.1667,0.25,0.3333,0.4167,0.5,0.5833,0.6667,0.75,...
0.8333,0.9167,1,1.0833,1.1667,1.25,1.3333,1.4167,1.5,1.5833,...
1.6667,1.75,1.8333,1.9167,2,6,9,22,34,46, 58,70,82,94,106,118,...
130,142,154,166,178,190,202,214,226];
ydata=[0.925,0.881,0.8604,0.8604,0.8409,0.8409,0.8409,0.8222,0.8222,0.8222,0.8044,...
0.8044,0.8044,0.8044,0.7872,0.7872,0.7872,0.7872,0.7708,0.7708,0.7708,0.7708,...
0.7708,0.7551,0.7255,0.7115,0.6727,0.6599,0.6491,0.6379,0.6271,0.6271,0.6167,...
0.6167,0.6066,0.6066,0.6066,0.5968,0.5968,0.5968,0.5873,0.5873,0.5873,0.5873];
x0=[5,3,5,2]; %初值
x=lsqcurvefit('curvefun1',x0,xdata,ydata)
f=curvefun1(x,xdata);
plot(xdata,ydata,'.')
hold on
plot(xdata,f,'.')
运行结果:
x =
1.0e+002 *
Columns 1 through 3
0.036322600853330 2.664204064307804 0.038239112150553
Column 4
0.000104652408479