How to build a 3D surface from a data file in Matlab

I have a data file with 3 columns, x, y, z and I would like to make a 3D graph to render the surface.

I could use meshgrid, but the problem is that I only have data for those y that y <= x. Is there any way to do this?

Example:

  xyz
 =============
 1 1 0.5
 2 1 0.3
 2 2 1.2
 3 1 1.1
 3 2 8.0
 3 3 1.4
 =============
+6
matlab
source share
3 answers

In many cases, a simple solution is to use trisurf. For example...

x = [1, 2, 2, 3, 3, 3]; y = [1, 1, 2, 1, 2, 3]; z = [0.5, 0.3, 1.2, 1.1, 1.8, 1.4]; tri = delaunay(x,y); trisurf(tri,x,y,z) 

alt text

+7
source share

You can definitively fill in the missing values, just a small script with two nested loops for x and y .

Otherwise, check the meshgrid function again in the MATLAB documentation. There you see the See Also section. It is no coincidence that the griddata function is present here. That's what you need! I can also recommend gridfit , which is even better.

+5
source share

You can place the surface through the points that you have, and then draw the surface. I like to use the x2fx function to generate a full quadratic model, and then use the \ operator to match the model data. Do you have any idea of ​​the fundamental nature of the surface you are trying to build? Does your data have a lot of noise? That 8.0 looks a little out of place, is this a jumble or is it the right data?

0
source share

All Articles