【问题标题】:3d velocity field plotting in matlabmatlab中的3d速度场绘图
【发布时间】:2013-05-17 15:07:09
【问题描述】:

我需要在 3d 球体上绘制彩色速度场。我正在寻找一个类似这样的函数:

f(X, Y, Z, V) 其中XYZ 表示 3d 坐标(使用 meshgrid 形成的 3 维矩阵),V 是一个 3 维矩阵,用于确定每个坐标的速度值协调。结果应该是一个 3d 彩色图,其颜色根据 V 中每个坐标的值而变化。

我尝试使用isosurface,但效果不佳,因为我需要轮廓,我只需要每个坐标中的特定值。我使用了quiver3,效果很好,但我需要用颜色而不是箭头来映射绘图。

我非常感谢任何想法和解决方案,因为我一直在阅读许多类似问题的大量 cmet(比如这个:How to plot 4D contour lines (XYZ-V) in MATLAB?)并且找不到任何解决方案。

提前谢谢你。

【问题讨论】:

    标签: matlab 3d


    【解决方案1】:

    我建议使用scatter3 函数。它是非常可定制的,可能正是您正在寻找的。​​p>

    http://www.mathworks.com/help/matlab/ref/scatter3.html

    【讨论】:

      【解决方案2】:

      我同意克里斯的回答。但是,提供一个关于如何使用 scatter3 的小例子可能是值得的:

      第一:

      x = rand(1,100);     % x-coordinates
      y = rand(1,100);     % y-coordinates
      z = rand(1,100);     % z-coordinates
      i = rand(1,100)*200;
      
      % specify the indexed color for each point
      icolor = ceil((i/max(i))*256);  
      
      figure;
      scatter3(x,y,z,i,icolor,'filled');
      % if you omit the 'filled' option, you'll just get circles
      

      第一个示例将根据变量i 为您提供颜色大小。如果您希望散点的颜色取决于i 的值但大小一致,请考虑第二种方法:

      x = rand(1,100);     % x-coordinates
      y = rand(1,100);     % y-coordinates
      z = rand(1,100);     % z-coordinates
      i = rand(1,100)*200;
      
      % specify the indexed color for each point
      icolor = ceil((i/max(i))*256);  
      
      % after setting the color based on i, reset i to be uniform
      i = ones(size(i)).*100;
      
      figure;
      scatter3(x,y,z,i,icolor,'filled');
      

      在定义颜色后重置i,所有散点的大小都相同。

      【讨论】:

      • 非常感谢你们的时间和精力。这个解决方案虽然我在一些试验后使用 'trisurf' 和 'convhull' 命令而不是工作。
      • 对于给定的数据矩阵 V,它看起来像这样:phi = -pi/2:a:pi/2; θ = 0:b:2*pi; r = r1:c:r2; [PHI, THETA, R] = meshgrid(phi, theta, r); [x, y, z] = sph2cart(THETA, PHI, R); x = x(:); y = y(:); z = z(:); M = convhull(x, y, z); trisurf(M, x, y, z, V, 'facecolor', 'interp', 'EdgeColor', 'none');
      • @Avshalom.Offner :如果您想给该评论更多空间,您可以回答自己的问题。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多