3D plotting, function approximation

8 Ansichten (letzte 30 Tage)
Peter Kerekes
Peter Kerekes am 16 Okt. 2017
Kommentiert: Peter Kerekes am 16 Okt. 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 Kommentare
Cam Salzberger
Cam Salzberger am 16 Okt. 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 am 16 Okt. 2017
Hello Cam !
Accordin to the exercise the points should be randomly selected, but maybe the evenly space is acceptable.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Delaunay Triangulation finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by