MATLAB Answers

Trouble understanding Isocolors and CData usage.

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)); 
      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.

0 Answers

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today