我需要绘制彩色速度场的三维球体。我在寻找一个功能,类似于此:
I need to plot a colored velocity field over a sphere in 3d. I'm looking for a function that looks similar to this:
F(X,Y,Z,V)
其中, X
,是
,以Z
重present的三维坐标(即使用的是形成3维矩阵 meshgrid
)和 V
是一个三维矩阵,它确定为每个坐标的速度值。结果应按照 V
每一个坐标。
f(X, Y, Z, V)
Where X
, Y
, Z
represent the 3d coordinates (3 dimensional matrices that are formed using meshgrid
) and V
is a 3 dimensional matrix that determines the velocity value for each coordinate. The result should be a 3d colored plot with a changing color according to the value in V
for every coordinate.
我试图用等值面
但它没有很好地工作,因为我需要的轮廓,我只需要在特定的值我在每一个坐标。我用 quiver3
和它的作品很好,但我需要的阴谋通过颜色映射,而不是箭头。
I tried to use isosurface
but it didn't work well because I need contours, I just need the specific value I have in every coordinate. I used quiver3
and it works well but I need the plot to be mapped by colors rather than arrows.
我真的AP preciate任何想法和解决方案,因为我一直在阅读了很多类似的问题,很多意见(像这样的:的如何绘制在MATLAB 4D轮廓线(XYZ-V)?),找不到任何解决方案。
I would really appreciate any ideas and solutions as I've been reading lots comments of many similar questions (like this one: How to plot 4D contour lines (XYZ-V) in MATLAB?) and couldn't find any solution.
感谢你在前进。
我同意克里斯的回答。但是,它可能是值得为如何 一个小例子scatter3
用于:
I agree with Chris's answer. However, it might be worthwhile to provide a little example on how scatter3
is used:
第一:
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
这第一个例子会给你颜色和基于变量尺寸我。如果你希望你的散点是在颜色依赖于
我
,但大小均匀,考虑第二种方法的值:
This first example will give you colors and size based on the variable i
. If you want your scatter-points to be in a color dependent on the value of i
but of uniform size, consider this second approach:
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');
有复位我
定义颜色后,所有的散点大小相等。
Having reset i
after defining the colors, all scatter-points are of equal size.