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)
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.
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.
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.
Thanks you in advance.
I would suggest using the
scatter3
function. It is very customizable, and may be exactly what you are looking for.http://www.mathworks.com/help/matlab/ref/scatter3.html
I agree with Chris's answer. However, it might be worthwhile to provide a little example on how
scatter3
is used:First:
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 ofi
but of uniform size, consider this second approach:Having reset
i
after defining the colors, all scatter-points are of equal size.