How do I make a surface plot from data points in 3 dimensions?

2 views (last 30 days)
I would like to make a 3D surface plot in MatLab that shows how one variable (Z) varies with two other variables (X and Y). The two varying variables (X and Y) are randomly generated and has no equal spacing. The only thing I can make work is scatter3(X,Y,Z), but that does not quite visualize the results as I would want it to. However, scatters3 shows a correlation that is representable with a surface.
The values are in vector form. One specific position in the vectors should be correlated to the same number in the other vectors, i.e Z(250) is calculated from X(250) and Y(250). As mentioned, X and Y are totally random, and should be.
How can I visualize with a 3D-surface, how Z varies with X and Y? I would like a colored surface if possible. I would like the actual values from X and Y to be shown in the plot, not just the vector position or similar.
Thank you in advance for any helpful answers.

Accepted Answer

Walter Roberson
Walter Roberson on 7 Feb 2014
Have a look at griddata() and at TriScatteredInterp and at the new griddedInterpolant.
Or perhaps you would prefer trisurf() after triangulating.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!