필터 지우기
필터 지우기

fit function to data

조회 수: 1 (최근 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 CenterFile Exchange에서 Power and Energy Systems에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by