How could I represent 3D scattered data without interpolation?
5 views (last 30 days)
Show older comments
Dear community,
I've been struggling for a while to plot my 3D scattered data. The data consist of x,y,z values, that are not ordered at all. This is what the data looks like in scatter3:

The problem is that I would like to use contourf for better visualization on a glance. No matter what approach I've chosen, Delaunay triangulation always leads to "cake-like" structures like it is shown here:

I have tried different approaches:
1)
xnodes = linspace(min(x),max(x),length(z))';
ynodes= linspace(min(y),max(y),length(z))';
[X,Y] = meshgrid(xnodes,ynodes);
data=griddata(x,y,z,X,Y);
contourf(xnodes,ynodes,z);
Problem: Delaunay triangulation links points that are not close to each other, creating the "cake-like" structure again.
2) I tried delaunay triangulation:
tri=delaunay(x,y);
trisurf(tri,x,y,z)
Same problem as above.
3) I have ordered all the data in depencence of their angle and tried above operations again. Same result.
4) I deleted all triangles from the triangulation, that were bigger than a certain value:
A=[0,0,0]
tri=delaunay(x,y);
for l=1:length(tri)
if abs(median(tri(l,:))-mean(tri(l,:)))>5;
tri(l,:)=A;
end
end
tri(all(tri==0,2),:)=[]
trisurf(tri,x,y,z)
This approach works!

The only problem that's left is, that I cannot plot contourf with triangulated data.... I tried to modify griddata.m, but could not implement my code, because griddata uses
DelaunayTriangulation
instead of
delaunay
I cannot alter any values there, so that I get the same result as in my code...
Any suggestions, on i) applying my code to DelaunayTriangulation? ii) my approach in general - am I on the right way? iii) alternative routes, to finally plot my data in a satisfactory way?
Thank you in advance!
Martin
Answers (1)
John D'Errico
on 29 Jun 2017
Edited: John D'Errico
on 29 Jun 2017
Your data does NOT live in 3-dimensions. This is a problem when you try to use delaunayn, because it assumes that your data does live in 3-d.
As you saw when you did try delaunayn, it spanned the hole with large simplexes. That is simply wrong, because it makes no sense to connect one side of that object with the other. Instead, you need to connect points with their neighbors. That means you really want to work in the subspace of the cylindrical surface. Converting to polar coordinates would seem to be a start.
So one simple idea is to convert all data to (r,theta,z) coordinates. Do a delaunay triangulation in the variables (z,theta). That will create a triangulation, NOT a 3-d tessellation composed of tetrahedra. In fact, you want to build a triangulation.
Finally, using the triangulation you just created, use trimesh to visualize the complete surface. Or use can use patch. A nice way to visualize it using patch is to then use the variable r to create the pseudo-coloring.
The only problem with the above approach is the triangulation will not connect the mesh around the 0/360 periodic transition. However if it bothers you, even that can be corrected with a little effort.
Without your data, I cannot easily show you any results. If you attach a comment here, then attach the data in a .mat file, then I can see if I can add some further help.
0 Comments
See Also
Categories
Find more on Delaunay Triangulation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!