MATLAB:根据散点创建彩色曲面

时间:2016-03-15 21:41:15

标签: matlab matlab-figure surface colormap

使用格式[x,y,z,value]的数据集,我可以创建一个3D散点图,如图所示,其中位置(x,y,z)上每个点的颜色基于value。请注意,所有图像都是相同的图,只是来自不同的视图。它旨在成为球体八分圆的表面。

enter image description here enter image description here

有没有办法可以对3D中的颜色进行插值,这样我们才能看到固体表面而不是单个点?我正在寻找imagesc的内容,但是在3D中。我尝试了各种各样的功能,包括scatteredInterpolantpatchmeshsurf,但这些功能似乎不像我那样在3个维度上工作我喜欢。

1 个答案:

答案 0 :(得分:0)

根据您的示例数据(带有多个shell),我将此程序放在一起。它使用trisurf,因此它不需要网格数据。

function PlotColoredSpheres(x,y,z)
    tol = 0.01;

    r = sqrt(x.^2 + y.^2 + z.^2);
    data = num2cell(sortrows([r, x, y, z], [1,2,3,4]),1);
    [R, X, Y, Z] = data{:};

    figure(1)

    RUnique = uniquetol(r, tol);

    for Ru = RUnique(:)'
        j = abs(R - Ru) < tol;
        tri = delaunay(X(j),Y(j));
        trisurf(tri, X(j), Y(j), Z(j));
        lighting phong
        shading interp
        hold on
    end
    hold off
end
相关问题