Search code examples
matlab3dsurface

Draw surface of 3D cloud in matlab


I have 3D cloud of dots. I need to plot them as a surface. I tried variant with meshdrid, griddata, scatteredInterpolant,trisurf-delaunay. Nothing works. I know that this question was discussed a lot, but it seems I don't understand some important details. The code which i have now:

load('coords.mat')
figure()
subplot(1,2,1)
plot3(x,y,z,'.')
axis off
view(3)

subplot(1,2,2)
C=gray(numel(x)); % unsuccessful attempt
[~,idx]=sort(z);  %      to have 
C=C(idx,:);       %    illumination
scatter3(x,y,z,50,C,'filled')
axis off
view(3)

produces the following image: enter image description here

Could you help me:

1) to find a way to draw it with surface function.

and as some dots may be inside the surface (may be it is my problem)

2) How to remove 'invisible' dots?

I need solution for different cases, picture and data presents just an example.

Mat file may be downloaded here.

P.S.

In case it is important – I obtain coordinates of this dots as a rotation of random bezier curve.

UPDATE

In case data above is too big I generate another set with smaller amount of dots:

enter image description here

Coordinates are here.


Solution

  • where do you get this data from? It is represented as vectors but if you reshape it to matrices you can use the surf function. Try this code:

    z=reshape(z,100,100);
    y=reshape(y,100,100);
    x=reshape(x,100,100);
    surf(x,y,z)