Function for best fitting

I've got a set of data :Y(d). And I am trying to approximate this set for an polynomial function in the following form :
So the problem is to find the values of each constant : "a,b,c,e" , for the best fitting!
So does someone know an possible way to do it,maybe some function ?
Obs:The set of data is quite big , so by "multiple iterations" I don't think Matlab can process some rotine.

1 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 21 日
It does'nt look like a polynomial function

サインインしてコメントする。

 採用された回答

Star Strider
Star Strider 2012 年 11 月 21 日

1 投票

There are several ways to do it.
First, write your function as:
% a = B(1), b = B(2), c = B(3), e = B(4)
% Y(d)=(a+b*d)/(c + e*d^3)
Y = @(B,d) (B(1) + B(2).*d) ./ (B(3) + B(4).*d.^3);
then, with d as your dependent variable and y as your independent variable:
Beta0 = rand(4,1);
[Beta,R,J,CovB,MSE] = nlinfit(d, y, Y, Beta0); % Statistics Toolbox
or:
[Beta,resnorm,residual,exitflag,output,lambda,jacobian] = lsqcurvefit(Y, Beta0, d, y); % Optimization Toolbox (allows parameter constraints)
If you do not have access to the Statistics or Optimization Toolboxes, I suggest you use fminsearch and the examples in Curve Fitting via Optimization. (The documentation explains it better than I could.) In that example, replace the start_point line with:
start_point = rand(4,1);
and the FittedCurve line with:
FittedCurve = (params(1) + params(2).*xdata) ./ (params(3) + params(4).*xdata.^3);
which is the code for your function.

2 件のコメント

Israel
Israel 2012 年 11 月 22 日
Thank you
Star Strider
Star Strider 2012 年 11 月 22 日
My pleasure!

サインインしてコメントする。

その他の回答 (2 件)

Matt J
Matt J 2012 年 11 月 21 日
編集済み: Matt J 2012 年 11 月 21 日

1 投票

Use LSQCURVEFIT if you have it.

1 件のコメント

Israel
Israel 2012 年 11 月 22 日
Thank you

サインインしてコメントする。

Matt J
Matt J 2012 年 11 月 21 日
編集済み: Matt J 2012 年 11 月 21 日

0 投票

If noise is sufficiently negligble, you could also rewrite the problem as a linear fitting:
d=d(:);
Y=Y(:);
w=ones(length(d),1);
A=[w,d,-Y, -Y.*d.^3];
[~,~,V]=svd(A);
abce=V(:,end);
If nothing else, this could generate a good initial guess for LSQCURVEFIT.

カテゴリ

ヘルプ センター および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by