Curve fitting nonlinear data sets by tuning multiple parameters

12 ビュー (過去 30 日間)
Shahriar Mahmud
Shahriar Mahmud 2021 年 8 月 7 日
コメント済み: Matt J 2021 年 8 月 9 日
Hi, I have multiple data sets (rn 5 sets but may increase later). I need to find out the values of three parameters C, a and b in order to best fit these three data sets. The function is as follows:
z=C*x^a*y^b
The datasets I got is as such, each data set has a given y. And once i change x, z changes. How do I tune C,a and b?
Thanks.
  2 件のコメント
Matt J
Matt J 2021 年 8 月 7 日
編集済み: Matt J 2021 年 8 月 7 日
So, for each data set, x is a vector and y is a scalar?
And it what form are the data sets stored? A cell array?
Shahriar Mahmud
Shahriar Mahmud 2021 年 8 月 7 日
Yes x is a vector and Y is a scaler. The z data and x data sets are stored in separate arrays.

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

採用された回答

Matt J
Matt J 2021 年 8 月 7 日
編集済み: Matt J 2021 年 8 月 7 日
You can get an initial guess using log-linear fitting,
n=[numel(x1),numel(x2),numel(x3)]; %concatenate data
X=[x1(:);x2(:);x3(:)];
Y=repelem([y1;y2;y3],n);
Z=[z1(:);z2(:),z3(:)];
p=[X.^0,log(X),log(Y)]\log(z); %linear algebraic solution
C0=exp(p(1)); %Initial estimates
a0=p(2);
b0=p(3);
Then you could refine with fminspleas (Download),
[ab,C]=fminspleas({@(ab,Q) prod(Q.^ab,2)} ,[a0,b0], [X,Y],Z );
a=ab(1);
b=ab(2);
  2 件のコメント
Shahriar Mahmud
Shahriar Mahmud 2021 年 8 月 8 日
編集済み: Shahriar Mahmud 2021 年 8 月 8 日
Thanks @Matt J, it worked. I have an additional question though. How do I evaluate this non-linear fit as R2 is not a viable option?
Matt J
Matt J 2021 年 8 月 9 日
Can't you just calculate R2 yourself? It's a pretty easy formula.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by