matlab有进行洛伦兹拟合的函数吗?
我用过高斯拟合的函数,比如说:fit(d',b1','Gauss2','MaxIter',1000);进行洛伦兹拟合的话是不是把'Gauss2'换成相应的参数就行了?如果进行洛伦兹拟合的话应该用什么参数呢?或者还有其它能进行洛伦兹拟合的函数吗? 你可以用cflibhelp看一下有没有这种拟合模型 The Curve Fitting Library is a library of models for data fitting
with the FIT function.
These models are divided into groups according to the type of
equations being modeled.
The groups are
GROUP DESCRIPTION
distribution: distribution models such as Weibull
exponential : models involving exponential terms
fourier : initial terms of fourier series up to eighth order
gaussian : sum of gaussian models up to eighth order
interpolant : interpolants
polynomial : polynomial models up to ninth order
power : power function and sum of two power functions
rational : rational equation models
sin : sum of sin functions up to eighth order
spline : splines
To list only the model equations for a group, type CFLIBHELP
followed by the group name.
Example:
cflibhelp polynomial
All models in the Curve Fitting Library:
DISTRIBUTION MODELS
MODELNAME EQUATION
weibull Y = a*b*x^(b-1)*exp(-a*x^b)
EXPONENTIAL MODELS
MODELNAME EQUATION
exp1 Y = a*exp(b*x)
exp2 Y = a*exp(b*x)+c*exp(d*x)
FOURIER SERIES
MODELNAME EQUATION
fourier1 Y = a0+a1*cos(x*p)+b1*sin(x*p)
fourier2 Y = a0+a1*cos(x*p)+b1*sin(x*p)+a2*cos(2*x*p)+b2*sin(2*x*p)
fourier3 Y = a0+a1*cos(x*p)+b1*sin(x*p)+...+a3*cos(3*x*p)+b3*sin(3*x*p)
...
fourier8 Y = a0+a1*cos(x*p)+b1*sin(x*p)+...+a8*cos(8*x*p)+b8*sin(8*x*p)
where p = 2*pi/(max(xdata)-min(xdata)).
GAUSSIAN SUMS (Peak fitting)
MODELNAME EQUATION
gauss1 Y = a1*exp(-((x-b1)/c1)^2)
gauss2 Y = a1*exp(-((x-b1)/c1)^2)+a2*exp(-((x-b2)/c2)^2)
gauss3 Y = a1*exp(-((x-b1)/c1)^2)+...+a3*exp(-((x-b3)/c3)^2)
...
gauss8 Y = a1*exp(-((x-b1)/c1)^2)+...+a8*exp(-((x-b8)/c8)^2)
INTERPOLANT
INTERPTYPE DESCRIPTION
linearinterp linear interpolation
nearestinterp nearest neighbor interpolation
splineinterp cubic spline interpolation
pchipinterp shape-preserving (pchip) interpolation
POLYNOMIAL MODELS
MODELNAME EQUATION
poly1 Y = p1*x+p2
poly2 Y = p1*x^2+p2*x+p3
poly3 Y = p1*x^3+p2*x^2+...+p4
...
poly9 Y = p1*x^9+p2*x^8+...+p10
POWER MODELS
MODELNAME EQUATION
power1 Y = a*x^b
power2 Y = a*x^b+c
RATIONAL MODELS
Rational Models are polynomials over polynomials with the leading coefficient
of the denominator set to 1. Model names are ratij, where i is the order of the
numerator and j is the order of the denominator. The orders go up to five for
both the numerator and the denominator. For example:
MODELNAME EQUATION
rat02 Y = (p1)/(x^2+q1*x+q2)
rat21 Y = (p1*x^2+p2*x+p3)/(x+q1)
rat55 Y = (p1*x^5+...+p6)/(x^5+...+q5)
SUM OF SIN FUNCTIONS
MODELNAME EQUATION
sin1 Y = a1*sin(b1*x+c1)
sin2 Y = a1*sin(b1*x+c1)+a2*sin(b2*x+c2)
sin3 Y = a1*sin(b1*x+c1)+...+a3*sin(b3*x+c3)
...
sin8 Y = a1*sin(b1*x+c1)+...+a8*sin(b8*x+c8)
SPLINES
SPLINETYPE DESCRIPTION
cubicspline cubic interpolating spline
smoothingspline smoothing spline 原帖由 vibshare 于 2006-8-14 21:25 发表
你可以用cflibhelp看一下有没有这种拟合模型
这么看来是没有洛伦兹拟合啦? 好像是没有,需要自己写代码 原帖由 vibshare 于 2006-8-14 21:39 发表
好像是没有,需要自己写代码
多谢! 拟合方程什么样的?
如果拟合方程能够给出来,matlab实现起来也不困难
不过可能会碰到初值的选取问题 原帖由 happy 于 2006-8-15 09:25 发表
拟合方程什么样的?
如果拟合方程能够给出来,matlab实现起来也不困难
不过可能会碰到初值的选取问题
其实我就是对一组数据进行拟合,需要知道拟合出来的峰值(y)对应的横坐标(x),如:
X=[
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24]
Y=[
22274 29600 41118 56346 83056 128804 187105 257344 322412 383516 416329 431047 433702 424422 398539 340765 270589 190081 123456 83148 59149 41192 29408 20589]
虽然用fit(d',b1','Gauss2','MaxIter',1000)这个函数可以拟合出来峰位约为12.6,但是觉得速度慢了一些。洛伦兹拟合也可以给出一个峰位,想试一下速度会不会快一些。 不好意思,不知道洛伦兹的拟合函数表达式是什么样的
如果有表达式的话很多函数应该都能实现 洛伦兹拟合函数: y = p1+2*p2/pi*p3/(4*(x-p4)^2+p3^2)
高斯拟合函数: y = p1+p2/(p3*sqrt(pi/2))*exp(-(2*(x-p4)^2/p3^2))
对于cauchenyu的数据:
洛伦兹拟合函数:
p1 -124305.537715397
p2 11032195.2501208
p3 12.0844406736081
p4 12.5755491636434
均方差(RMSE): 15882.2076659963
相关系数(R): 0.994700355729377
高斯拟合函数
p1 6753.50914863686
p2 -4629285.10441749
p3 -8.2999354559485
p4 12.574216703645
均方差(RMSE): 9668.32080744164
相关系数(R): 0.998039347117299
从结果看,高斯函数比洛伦兹函数更好一些。用1stOpt算的,用时不超过1秒 客观的讲1stOpt在做拟合方面还是不错的 来支持一下,刚来看得不太明白。
页:
[1]