MATLAB: How to make plot a 3D matrix as a scatter plot with color based on value

3d plots

I have a 3D matrix cube(i,j,k) and I want to plot the points as a scatter plot. However, each point is a different temperature and I would like to color each point based on the temperature.
The result would be a cube i by j by k with i*j*k points and each point would vary in color based on the value assigned to the point.

Best Answer

[X,Y,Z] = ndgrid(1:size(cube,1), 1:size(cube,2), 1:size(cube,3));
pointsize = 30;
scatter3(X(:), Y(:), Z(:), pointsize, cube(:));
Related Question