3D plotting, function approximation

8 次查看(过去 30 天)
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 个评论
Cam Salzberger
Cam Salzberger 2017-10-16
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 2017-10-16
Hello Cam !
Accordin to the exercise the points should be randomly selected, but maybe the evenly space is acceptable.

请先登录,再进行评论。

回答(1 个)

Cam Salzberger
Cam Salzberger 2017-10-16
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 个评论
Peter Kerekes
Peter Kerekes 2017-10-16
Hello Cam !
Thanks a lot for your help. I've tried and work well.
Peter,

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Delaunay Triangulation 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by