Surface Fitting with a high order polynomial custom equation

Hello,
I am trying to use a 12th order polynomial custom equation in the Curve Fitting Tool GUI to get an equation of the gradient of the surface of a DVD from a few hundred data points, but the equation I am getting is ridiculous -- with an R-square value of -10^24.
Is there any way to force the fitter to keep iterating until the R-square value is close to 0?
In the "Fit options" menu, I have set Robust to be "Bisquare" and have told it to use a Trust-Region algorithm, with MaxIterations being 400000, MaxFunctionEvals being 60000... I am fairly sure that a 12th order polynomial will be sufficient.
I have attached a screenshot of the setup and the problem. (I am using a 2016 version)

回答(1 个)

A really, really, really bad idea. Massively bad.
You are trying to fit a polynomial model with roughly a hundred terms or so, to data that is clearly insufficient to estimate all of those terms. On top of that, you would have failed for numerical reasons anyway. It is simply not possible to estimate that model. Even if you did estimate something with non-garbage coefficients, the predictions between the points would be pure crap. Sorry, but all of this is true.
This is a common problem. People think that polynomials are wonderful things. After all, they are just like a Taylor series, and we all know that we can use Taylor series for anything, right? And, hey, a low order model works fine, but just is not quite good enough, so CRANK UP the order! WRONG. Just flat out wrong. Whoever told you that you can use a high order polynomial for this was in error, or if you decided to do it on your own,then so were you. Sorry, but true.
A 12th order polynomial model is NOT sufficient. It does not matter how many iterations you allow, how far down you want to crank the tolerance. Garbage will be the result. It does not matter what release you are using. Wanting to get something other than pure garbage from this polynomial model is not sufficient.
If you want a moderately decent approximation to the shape of the surface, I'd recommend using my gridfit to fit a surface over that domain. (Download gridfit from the FEX.) Then you can just use gradient to compute an estimate of the surface gradients over the domain. No matter what you do, that estimate will not be perfect.

3 个评论

Is fitting 2D data better done with gridfit or polyfitn?
Thank you for the response. Something I didn't make clear is that I already have the gradients and I need to find the relative height of the points on the DVD. This is why I had hoped to find a function for the data. Does Gridfit provide an easy way to do this?
Polyfitn is NOT a good tool to do 12th degree fits in two dimensions. NOT. No tool is a good choice for 12th degree polynomial fits in 2-d.
No, gridfit does NOT return a "function" that you can use. It returns essentially a table of data, on a now regular grid.
It sounds now like the data that you have is actually gradient data of some ilk, sampled at irregular points, and that you wish to integrate it to recover effective height information? Your further comments make it rather confusing as to what you actually have.
If that is wrong, and these are really sampled points, scattered over the surface of a CD, and you now wish to estimate the surface height, I would probably develop a model of the height in polar coordinates.

请先登录,再进行评论。

类别

在 帮助中心 和 File Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

提问:

2016-11-26

Community Treasure Hunt

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

Start Hunting!

Translated by