How do I interpolate and plot 3-D surfaces in MATLAB?
104 views (last 30 days)
Show older comments
MathWorks Support Team
on 10 Sep 2012
Edited: MathWorks Support Team
on 14 Oct 2022
I have vectors "x", "y" and "z" representing the 3 coordinates of points on a 3-D non-linear surface. I would like to interpolate the surface and plot the results.
Accepted Answer
MathWorks Support Team
on 14 Oct 2022
Edited: MathWorks Support Team
on 14 Oct 2022
MATLAB has surface fitting capabilities in the Curve Fitting Toolbox™ that provide an easy way to interpolate and plot surfaces in MATLAB. To learn about interactive surface fitting, please see the following link:
To learn about programmatic surface fit objects, please see the following link:
If you have a MATLAB version prior to R2009a, please read the following for workarounds.
The function GRIDDATA can be used to interpolate and plot data in 3-D as follows:
ZI = griddata(x,y,z,XI,YI) fits a surface of the form z = f(x,y) to the data in the (usually) nonuniformly spaced vectors (x,y,z). GRIDDATA interpolates this surface at the points specified by (XI,YI) to produce ZI. The surface always passes through the data points. XI and YI usually form a uniform grid (as produced by meshgrid).
You can also fit a spline to a surface defined by the data in the same sized matrices "x", "y", and "z", where "x" and "y" are plaid (evenly-spaced) meshes. An example of using the Curve Fitting Toolbox to perform this operation is included in our online documentation starting at the following URL: "Example: Approximation by Tensor Product Splines"
0 Comments
More Answers (0)
See Also
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!