Asked by Edwin Baldelomar
on 16 Jan 2013

Hello all,

I have a follow up question from a previous question I asked: So I have a [m n z] (3D) data set that gives me multiple spheres when rendered. I would like to color each individual sphere it's own unique color. After some research into matlab doc's, I came up trying to use 'isocolors'. It will uniformly change all the spheres but won't change each individual. I also understand that perhaps 'cdata' could perform this, but I'm a bit unclear how cdata works. When I try to use a map that is of the same dimensions [m n z] using 'CData', it gives me the following error:

Error using set CData must be an M-by-N matrix or M-by-N-by-3 array.

So this confuses me about CData; Let's say I have 5 spheres that are created in the original [m n z] data; how do I set up a M-by-N matrix that will color each uniquely? Does it have to be 5x1 or 1x5 matrix?

Here's my code that renders the data in 3D (where 'XX' is my [m n z] data):

p=patch( isosurface(XX,0)); isonormals(XX,p) isocolors(cdata,p) set(p,'FaceColor','interp','EdgeColor','none') daspect([1 1 .5]) view(3), axis vis3d tight, box on, grid off camproj perspective camlight, lighting phong, alpha(.5)

Any and all help would be much appreciated. Thank you!

Cheers, Edwin

*No products are associated with this question.*

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments