6

I have a data file with 3 columns, x, y, z and I would like to do a 3D plot to visualize the surface.

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

An example:

x    y    z
============
1    1    0.5
2    1    0.3
2    2    1.2
3    1    1.1
3    2    8.0
3    3    1.4
============
0

3 Answers 3

7

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

Sign up to request clarification or add additional context in comments.

1 Comment

Note: I assumed that the 8 was a typo in those numbers, so I put in 1.8. Also, if the data in the (x,y) plane does not represent a convex region, then delaunay will still force it to be convex. This may introduce interpolation artifacts around the edges.
5

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

Otherwise look again at the function meshgrid in the MATLAB documentation. There you see See Also section. Not accidentally there is a function griddata listed there. That's what you need! I can also recommend gridfit which is even better.

Comments

0

You could fit a surface through the points you have and then graph the surface. I like to use the x2fx function to generate a full quadratic model, then use the \ operator to fit the data to the model. Do you have any idea about the underlying nature of the surface you're trying to graph? Does your data have a lot of noise? That 8.0 looks a bit out of place, is that an outlier or is that proper data?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.