I want to use fit function to get the formula with its coefficient for my data. so i have used: [curve, goodness, output] = fit(fk,Rfft,'linearinterp'); in case of 'poly1' or 'poly2' the curve variable (which is in cfit format) shows the formula with its coefficients however when i use linearinterp the curve does not show the formula, it just says "piecewise polynomial". i need to get the formula with its coefficients. does anyone have any idea how to get the formula?
<<
>>

 채택된 답변

Vishwas
Vishwas 2017년 12월 7일

1 개 추천

There really isn't a formula for the surface. It's a piecewise linear surface so it's a single formula for a plane at each location of your data making it many formulas altogether.

추가 답변 (1개)

Bowen Song
Bowen Song 2019년 3월 16일
편집: Bowen Song 2019년 3월 16일

2 개 추천

Treat it as a string... lol check this out
[fitresult{1}, gof(1)] = fit( [xData, yData], zData, ft );
... from above you get your sfit or what not
f = string(formula(fitresult{1})); // get the formular in string format
names = coeffnames(fitresult{1}); // get the coeff names
vals = coeffvalues(fitresult{1}); // get those values
for i = 1:length(names)
f = strrep(f,string(names(i)),string(vals(i))); // replace the coeff names with values
end
eval(f) // muhaha

댓글 수: 3

I don't think this will work for piecewise polynomials. (At least not in MATLAB; you appear to be using Octave.)
Xiyan Li
Xiyan Li 2024년 4월 16일
I wonder how to get the equation out after piecewise fitting? It makes no sense to me without gettting the equation out.
The output is a piecewise polynomial. It does not have a single equation. It is effectively a list of equations that are each valid over a specific range.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

태그

질문:

2017년 11월 29일

댓글:

2024년 4월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by