MATLAB: RGB colors in scatter3

rgb scatter3

Im trying to plot n [X,Y,Z] dots in 3d with their colors given by C which is a nx3 matrix describing the RGB colors for each dot (graded colors)…. but its not working!!!!
scatter3(X,Y,Z,S,C, 'filled')
any suggestions?

Best Answer

Have a look at the example in the help:
[x,y,z] = sphere(16);
X = [x(:)*.5 x(:)*.75 x(:)];
Y = [y(:)*.5 y(:)*.75 y(:)];
Z = [z(:)*.5 z(:)*.75 z(:)];
S = repmat([1 .75 .5]*10,numel(x),1);
C = repmat([1 2 3],numel(x),1);
scatter3(X(:),Y(:),Z(:),S(:),C(:),'filled')