# Why the results from Matlab curve fitting function differ when using custom equation?

I'm using Matlab's curve fitting app, When I select Power fitting it returns values which perfectly describe the data but when I use the custom equation and enter ax^b as the equation it returns very bad coefficients. Shouldn't the results be the same?

I need to fit a data to a $$ax^{-6} + bx^{-4} + cx^{-2}$$ function so I need to use custom equation.

EDIT: Added the screenshots.

## 1 Answer

I think your value of $$y$$ is too small. So, when the sum of squares is calculated it is already below the threshold, and the coefficients are accepted as good ones.

And the power function is fitted differently. $$log(y) = log(a) + x*log(b)$$ is a linear regression that has a direct formula. While when you input it manually it is something close to gradient decent to minimize sum is squares.

I do not know Matlab well, but you can multiply $$y$$ by $$10^6$$ and fit the curve. Then the real $$a$$ coefficient is $$a/10^6$$. Or try clicking fit options button and search the threshold value there.

• Yes they are. So how should I increase this threshold? – Alireza Oct 29 '18 at 7:26
• I do not know Matlab well, but you can multiply y by 10^6 and fit the curve. Then the real a coefficient is a/10^6. Or try clicking fit options button and search the threshold value there. – keiv.fly Oct 29 '18 at 7:30