【问题标题】:4D plot (3D+color) from 4 row vectors来自 4 个行向量的 4D 图(3D+颜色)
【发布时间】:2016-07-06 07:29:21
【问题描述】:

我有 4 个行向量 x, y, z and s,它们的大小都相同 1*sizex, y, z 应该是三个笛卡尔坐标轴,s 应该用颜色表示(我想要下图)。语句Surf 不接受行向量。我已经阅读了几篇stackoverflow帖子,但我找不到答案。我怎样才能绘制这样的数字? 非常感谢您提供的任何帮助。

【问题讨论】:

    标签: matlab plot matlab-figure figure 4d


    【解决方案1】:

    由于您没有提供任何数据,我无法对其进行测试,但您可以尝试:

    trisurf(x,y,z,s)
    

    如果这不起作用,请尝试:

    DT = delaunayTriangulation(x,y,z);
    tetramesh(DT,s);
    

    【讨论】:

    • 谢谢@KiW。第一条语句导致此警告:Values in patch Faces must be in [1 : rows(Vertices)] - not rendering,第二条代码导致错误:Error using tetramesh (line 103) The number of colors should equal the number of tetrahedra.
    • 你有一些样本数据吗?
    【解决方案2】:

    您可以尝试使用这个 3D 立方体的示例来创建 3D 网格,它会绘制“温度”。

    L = 1;
    dx = 0.25;
    dy = dx;
    dz = dy;
    Nx = L/dx;   Ny = Nx;    Nz = Ny;
    x = dx/2:dx:L-dx/2;
    y = x;       z = y;
    [xx, yy, zz] = meshgrid(x,y,z);
    theta = NaN(size(zz));
    
    for jj=1:4;
        for ii=1:4
            for kk=1:4
                theta(jj,ii,kk) = 273.15 + 5.*random('normal', 0, 1)
            end
        end
    end
    
    clf
    isosurface(xx, yy, zz, theta)
    colorbar
    colormap jet
    [fe, ve, ce] = isocaps(x, y, z, theta, 10);
    p2 = patch('Faces', fe, 'Vertices', ve, 'FaceVertexCData', ce);
    p2.FaceColor = 'interp';
    p2.EdgeColor = 'none' ;
    grid on
    xlabel('X (m)');
    ylabel('Y (m)');
    zlabel('Z (m)');
    title('Temperatures');
    set(gca, 'clim', [273.15 273.15+5])
    set(get(colorbar, 'title'), 'string', 'K', 'FontW', 'bold', 'fontname', 'Times New Roman', 'fontsize', 14);
    view(3)
    

    【讨论】:

    • 非常感谢,萨达尔!
    猜你喜欢
    • 2012-07-12
    • 1970-01-01
    • 2018-12-06
    • 1970-01-01
    • 2013-03-04
    • 2015-03-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多