麻烦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,... 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的。就这些条件了。麻烦哪位会的同学,帮我解决下,在线等- -哪里看不清的可以说下。谢谢了。。。
展开
 我来答
771495269
2011-06-06 · TA获得超过224个赞
知道小有建树答主
回答量:157
采纳率:0%
帮助的人:188万
展开全部

我做了一下发现误差比较大,是不是我给的初值有问题,还是给的数据有问题,你可以参考下

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

追问
对不起,我的错,我给的Y值有问题,Y值是:y=[0.0123,0.0129,0.0132,0.0132,0.0135,0.0135,0.0135,0.0138,0.0138,0.0138,0.0141,0.0141,0.0141,0.0141,0.0144,0.0144,0.0144,0.0144,0.0148,0.0148,0.0148,0.0148,0.0148,0.0151,0.0157,0.016,0.0169,0.0172,0.0175,0.0178,0.0181,0.018,0.0184,0.0184,0.0188,0.0188,0.0188,0.0191,0.0191,0.0191,0.0194,0.0194,0.0194,0.0194]
X值不变。麻烦你再看看,耽误你时间了,不好意思。
victoriajll
2011-06-06 · TA获得超过4884个赞
知道大有可为答主
回答量:654
采纳率:100%
帮助的人:1049万
展开全部

你确定你的数据和方程有联系吗,我用其他方程拟合的,用你原来的方程拟合效果极差,我用的方程式y=a*exp(b*x)+c*exp(d*x)

更多追问追答
追问
不是用CFTOOL拟合的,你应该不是用的lsqcurvefit拟合的吧,这个需要初始值的- -
追答
用cftool可以自定义拟合方程,我把你的原始方程设成自定义拟合方程了,拟合之后完全不搭边,所以我换了指数拟合,感觉还好,所以我很怀疑你的数据和方程有联系吗。
我一般用lsqcurvefit拟合时,都是先用cftool拟合把初值找到,再编程的,但是发现完全不搭边,所以直接编程我感觉也拟合不出来,数据真没问题吗
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式