How can I create a best fit polynomial for my data?

5 ビュー (過去 30 日間)
Syed Ali Zaryab
Syed Ali Zaryab 2018 年 9 月 4 日
コメント済み: Titus Edelhofer 2018 年 9 月 9 日
I have a set of data points that I received from a supplier which gives relative efficiency based on values of x and y. I want to create a polynomial similar to the one given below using the data provided Efficiency = a * (x)^2 + b * (x*y) + c * (y)^2 + d * (x)+ e * (y) + f
So basically what I want is a function which optimizes the value of a,b,c,d,e and f for me and gives me results that are almost similar to the one in the data table.
Attached herewith is the picture of the graph that the supplier provided along with the data points. Can you please tell me what functions can I use in Matlab to help me achieve this task.

採用された回答

Titus Edelhofer
Titus Edelhofer 2018 年 9 月 4 日
Hi Syed,
if I assume you have three (column) vectors x, y and Efficiency, then it's simply a linear regression problem:
A = [x.^2 x.*y y.^2 x y ones(size(x))];
sol = A \ Efficiency;
Then sol contains the (best approximation) values a,...,f.
Titus
  3 件のコメント
Torsten
Torsten 2018 年 9 月 7 日
Use "reshape" to change x, eff and y from (4x13) matrices to (52x1) vectors.
Titus Edelhofer
Titus Edelhofer 2018 年 9 月 9 日
Or use (:), i.e.,
x = x(:);
y = y(:);
eff = eff(:);
Titus

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

その他の回答 (0 件)

カテゴリ

Help Center および 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