3D plotting, function approximation
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
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?
Respuestas (1)
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
Ver también
Categorías
Más información sobre Delaunay Triangulation 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!