Fitting surface only to the top layer of points
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ingo Rück
el 25 de Oct. de 2017
Comentada: Ingo Rück
el 26 de Oct. de 2017
Hello everyone,
I have a big number of points that I want to turn into contour plot. The problem is the points are on top of each other, as you can see in the picture. I tested all the options the curve fitting toolbox has to over, the surface in the picture is made by using the loessfit option. The surface I want to create should almost look like the one in the picture, but only using the points on top.
Is there another way to create a surface, like lowering a blanket over the cloud of points? The only option I see is manualy deleting all the underlying points and then create the surface, but experience taught me that there is always a faster way when it comes to Matlab.
Thank you for your help!
0 comentarios
Respuesta aceptada
John D'Errico
el 25 de Oct. de 2017
You have not provided your data, so I cannot show you how to solve the problem on your data. I guess I could make up some data. But then I would need to write the code too. :-(
The solution that I have usually found to work to create such an envelope is not that incredibly difficult, but difficulty is defined by the eyes of the beholder. Really, it is a simple enough trick:
Solve for a least squares surface, subject to the constraints that the residuals are all of the same sign. Thus here we would have
zhat - z >= 0
Apply this constraint to EVERY data point. Now use whatever model you wish to fit the surface, but you will need to employ a fitting tool that can allow inequality constraints. If you have 1000 data points, then you will have 1000 inequality constraints on the solution.
My recommendation would be to fit a surface like that I use for gridfit, so perhaps a tensor product linear surface. Were it me solving the problem, I'd add in a regularization term to smooth the surface, again like gridfit. But I would solve the problem using lsqlin, because lsqlin allows you to provide linear inequality constraints.
Simplest would be to hack gridfit, adding in the linear inequality constraints, then call lsqlin. Sadly, gridfit does not allow this as a solution. I do offer the option of such an envelope constraint in my SLM toolbox, where it works nicely enough. But SLM applies only to 1-d problems.
To show you that the idea does work very nicely, here is an example using SLM.
x = rand(1,100);
y = x.^2 - rand(size(x))/10;
slm = slmengine(x,y,'knots',0:.2:1,'plot','on','increasing','on','concaveup','on','envelope','supremum')
Since I know that the noise is always additive and negative, a supremum (least upper bpound) fit seems correct.
You need to do the same thing, but applied to a 2-d surface. Since the choice of how to do it would depend on the specific model involved, either lsqlin or fmincon would be necessary.
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!