fit function to data

2 ビュー (過去 30 日間)
ignacio bobadilla tapia
ignacio bobadilla tapia 2021 年 6 月 25 日
コメント済み: Walter Roberson 2021 年 6 月 25 日
Hello, please, if you could help me to fit a function to a data series, I understand that the matlab 'fit' function works excellent, but I don't know how to implement it. What I have to do is fit the best possible function to the data series, but the problem that I have two series 'x1' and 'x2', e 'y1' and 'y2', where they all go in a single figure, for which I write down the code I have. I attach the data. Thanks greetings.
load x1.txt , load x2.txt , load y1.txt , load y2.txt
plot(x1,y1,'or',x2,y2,'or')

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 6 月 25 日
load x1.txt , load x2.txt , load y1.txt , load y2.txt
plot(x1,y1,'or',x2,y2,'b*') % Differentiate different data sets while plotting them
FM1=fit(x1,y1,'poly2'); % Quadratic fit model
FM2=fit(x2,y2,'poly2'); % Quadratic fit model
...
  2 件のコメント
ignacio bobadilla tapia
ignacio bobadilla tapia 2021 年 6 月 25 日
I want all the data to be represented with only one function, that is, that x1 and x2 are the same matrix, and y1 and y2 are another matrix, then calculate the function. If you could help me please.
Walter Roberson
Walter Roberson 2021 年 6 月 25 日
x = [x1(:);x2(:)];
y = [y1(:);y2(:)];
FM = fit(x, y, 'poly2'); % Quadratic fit model
plot(FM, x)

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

カテゴリ

Help Center および File ExchangePower and Energy Systems についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by