How to use least square fit in MATLAB to find coefficients of my polynomial?

1 回表示 (過去 30 日間)
Majid Vaghari
Majid Vaghari 2021 年 2 月 3 日
コメント済み: Jeff Miller 2021 年 2 月 5 日
I have some experimnetal data for H and I like to use lease square method with matlab to fit my data with my polynomial (attached file is polynomial)
Ci is the atomic fraction of element. i have 5 elements .
I have the experimnetla data. how can i use matlab for this least square fit?

採用された回答

Jeff Miller
Jeff Miller 2021 年 2 月 3 日
% It sounds like you have data arrays like these:
nPoints = 100;
H = rand(nPoints,1);
C = rand(nPoints,5);
% If so, compute the least square estimates of the a's and b's with this:
Csqr = C.^2;
ab_ests = regress(H,[C Csqr]);
% the first 5 values of ab_ests are the estimates of the a's,
% and the second 5 are the estimates of the b's
  2 件のコメント
Majid Vaghari
Majid Vaghari 2021 年 2 月 5 日
Thank you for yoru answer Jeff Miller, that was what I wanted and it worked correctly.
Thank you very much
Jeff Miller
Jeff Miller 2021 年 2 月 5 日
Please "accept" the answer to indicate that the question has been resolved.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePolynomials についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by