用过matlab拟合曲线的请进来

拟合曲线有哪些现成指令可以用?
书上只介绍了降次排列的多项式系数,用的是最小二乘法。
结果是Y=a0*X^2+a1*X+a2的形式,
现在我要求是写成Y=a*(U-b)^2的形式,只有两个参数。
怎么才能实现这个功能?有现成的指令可以用么?还是用最小二乘法编程序?
本人的matlab是盗版的,当时安装时候没有安装documentation。
热心人请介绍一下关于曲线拟合的指令集,谢谢!rose.gif
Share |
Share

想用最小二乘法算Y=a*(x-b)^2的参数a和b,有人能给点建议,提供算法或者代码么?

TOP

你就没自己在google上找过?
还和我说找不到

用最小二乘法 和 matlab 找找
冬冤家,我有心将你打,却一个心儿怕;要不打,只恨你这冤家羞人煞;罢罢罢,低眉红了脸儿帕,嫁了吧!

TOP

装了Matlab不装文档,怎么活啊?
我给你传算了:)

TOP

i do not understand why don`t you rewritten the equations Y=a*(U-b)^2 just to the form Y=a*U.^2-2*a*b*U+a*b*b.  then you can calculate the a, b from these three terms. and then use polyfit .Although 3 eqs 2 parameters, leads to overdetermined problem, if the deviations are not so big, it will be in tolerance.
definitely you can also write a m-function (or for state space s-function) with LSQ or RLS algorithm. there are lots of papers about that in internet. and not so complicated. for estimate the parameter of a transfer function you can also use toolbox Ident.  just enter ident in the command line, you will see it.
but anyway parameter estimation or curve fitting are really boring and chanllenging work.  it needs time to get good at it.

[ Last edited by ASDF on 2005-12-8 at 16:14 ]

TOP

the function in matlab is   ....polyfit.....
the general idea of LSQ is just based on the form

Y=phi*theta
Y and phi are the measurement matrix
theta is the parameters matrix

start from a initial value of theta, we get
Y_head=phi(t_0)*theta(t_0)
minimize the deviation Error=Y-Y_head, we get the estimated theta(t_1) for the next time step,, and so on.  so generally you should rewrite the equations in the form of Y_head=phi(t_0)*theta(t_0), firstly . even for the ODE or PDE equations, you should also discretize them as the first step of the estimation process.

TOP

回答楼上的,polyfit只能提供降次的,事实证明误差很大。
找到一个曲线拟合的好函数,lsqcurvefit。
不过还是谢谢!:)

TOP

Originally posted by jiejiedog at 2005-12-9 09:47 AM:
回答楼上的,polyfit只能提供降次的,事实证明误差很大。
找到一个曲线拟合的好函数,lsqcurvefit。
不过还是谢谢!:)

回家后上msn找我
我传你一个带文档的matlab
冬冤家,我有心将你打,却一个心儿怕;要不打,只恨你这冤家羞人煞;罢罢罢,低眉红了脸儿帕,嫁了吧!

TOP

我一直用的是ployfit ,去试试lsqcurvefit看看:)

TOP

如果只是为了得到较好拟合曲线的未知参数,可以使用cftool

TOP