Does the curvefit toolbox return the equation for the best fit line (or curve)?
2 views (last 30 days)
Show older comments
For example, let's say that a 5th order polynomial fits the data nicely. Does the curvefit results include the equation, or at least the coefficients, of the 5th order polynomial fit?
Perhaps a silly question, but you might be surprized at how many so-called curve fitting programs are out there that only care about displaying the fit.
Thank you for considering my question.
Todd
1 Comment
Accepted Answer
the cyclist
on 14 May 2024
3 Comments
Steven Lord
on 14 May 2024
And if you export the fit from the app using the last button on the toolstrip, you'll get a cfit or sfit object. You can use a number of different functions to post-process them.
load census
format longg
f = fit(cdate, pop, 'poly2')
formula(f)
coeffnames(f)
coeffvalues(f)
Note that not all types of fit give formulas you can use to evaluate the fit.
f2 = fit(cdate, pop, 'spline')
formula(f2)
But then again you don't need to use the formula to evaluate it if you have the object.
populationFromQuadratic = f(1849)
populationFromSpline = f2(1849)
More Answers (0)
See Also
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!