matlab用最小二乘法求一形如y=t/(at+b)(a和b为待定系数)的多项式,使之与下列数据相拟合
数据如下t=[12345678]y=[4.006.408.008.809.229.509.709.68]...
数据如下t=[1 2 3 4 5 6 7 8] y=[4.00 6.40 8.00 8.80 9.22 9.50 9.70 9.68]
展开
2个回答
展开全部
First, write a file to return the value of F (F has n components).function F = myfun(x,xdata)
F = x(1)*exp(x(2)*xdata);Next, invoke an optimization routine:% Assume you determined xdata and ydata experimentally
xdata = ...
[0.9 1.5 13.8 19.8 24.1 28.2 35.2 60.3 74.6 81.3];
ydata = ...
[455.2 428.6 124.1 67.3 43.2 28.1 13.1 -0.4 -1.3 -1.5];
x0 = [100; -1] % Starting guess
[x,resnorm] = lsqcurvefit(@myfun,x0,xdata,ydata);At the time that lsqcurvefit is called, xdata and ydata are
assumed to exist and are vectors of the same size. They must be the
same size because the value F returned by fun must
be the same size as ydata.
F = x(1)*exp(x(2)*xdata);Next, invoke an optimization routine:% Assume you determined xdata and ydata experimentally
xdata = ...
[0.9 1.5 13.8 19.8 24.1 28.2 35.2 60.3 74.6 81.3];
ydata = ...
[455.2 428.6 124.1 67.3 43.2 28.1 13.1 -0.4 -1.3 -1.5];
x0 = [100; -1] % Starting guess
[x,resnorm] = lsqcurvefit(@myfun,x0,xdata,ydata);At the time that lsqcurvefit is called, xdata and ydata are
assumed to exist and are vectors of the same size. They must be the
same size because the value F returned by fun must
be the same size as ydata.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询