Azzera filtri
Azzera filtri

fit function to data

1 visualizzazione (ultimi 30 giorni)
ignacio bobadilla tapia
ignacio bobadilla tapia il 25 Giu 2021
Commentato: Walter Roberson il 25 Giu 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')

Risposte (1)

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

Accedi per commentare.

Categorie

Scopri di più su Power and Energy Systems in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by