fit function to data

2 vues (au cours des 30 derniers jours)
ignacio bobadilla tapia
ignacio bobadilla tapia le 25 Juin 2021
Commenté : Walter Roberson le 25 Juin 2021
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')

Réponses (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 25 Juin 2021
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 commentaires
ignacio bobadilla tapia
ignacio bobadilla tapia le 25 Juin 2021
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 le 25 Juin 2021
x = [x1(:);x2(:)];
y = [y1(:);y2(:)];
FM = fit(x, y, 'poly2'); % Quadratic fit model
plot(FM, x)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Power and Energy Systems dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by