3D plotting, function approximation

8 visualizaciones (últimos 30 días)
Peter Kerekes
Peter Kerekes el 16 de Oct. de 2017
Comentada: Peter Kerekes el 16 de Oct. de 2017
Hello !
I do have some problem with plotting 3d function.
I have 3 column vector (X1,X2,Y) (X1,X2 is the input coordinate Y is the value in (X1,X2) coordinate) Y has the same dimension as X1,X2. I wolud like to plot Y in 3D. I was trying use [A,B]=meshgrid(X1,X2) and after surf(A,B,Y) but Y has wrong dimension to use surf(). Can anybody help, how can I transform Y to have the proper dimension? (The function between (X1,X2) and Y is unknown, I now only the value of Y in the current points)
Thank you!
  2 comentarios
Cam Salzberger
Cam Salzberger el 16 de Oct. de 2017
Hello Peter,
Are X1 and X2 evenly spaced? Like:
X1 = [1 2 3 4 1 2 3 4 1 2 3 4];
X2 = [5 5 5 5 6 6 6 6 7 7 7 7];
Because that would make this really convenient. Or are the points totally randomly-placed?
Peter Kerekes
Peter Kerekes el 16 de Oct. de 2017
Hello Cam !
Accordin to the exercise the points should be randomly selected, but maybe the evenly space is acceptable.

Iniciar sesión para comentar.

Respuestas (1)

Cam Salzberger
Cam Salzberger el 16 de Oct. de 2017
Hey Peter,
If the points are random, then generally you would plot them in 3-D as singular points in three dimensions:
plot3(X1, X2, Y, 'ok')
Alternatively, you can depend on Delaunay triangulation to make a surface between the points, and then display that:
tri = delaunay(X1, X2);
trisurf(tri, X1, X2, Y);
If you really want to use "surf", you could create a scatteredInterpolant, make your query points into an evenly-spaced grid, and then display that with surf. That's probably not necessary though. I would guess that delaunay and trisurf would suffice for your needs.
-Cam
  1 comentario
Peter Kerekes
Peter Kerekes el 16 de Oct. de 2017
Hello Cam !
Thanks a lot for your help. I've tried and work well.
Peter,

Iniciar sesión para comentar.

Categorías

Más información sobre Delaunay Triangulation en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by