3D Matrix to create 3D graphic
Show older comments
My goal:
I have a 3D matrix with 50x50x50 (x,y,z). This Matrix creates a fixed dice. In each point(x,y,z) I have a value. Those values combined should create the colors. Just for interest, the idea behind a lot of high values f.e. are red colored and form to a shape, because of their position in the dice (x,y,z). lower values f.e. are blue and are all over the place. In fact, they dont form to a shape.
I was reading before a couple of blogs about that topic and havent found any right answers for me. May be I overread somewhere a good one. Its possible=)
Thats why thats not how I want it:
If I transfer my data to multiple 2D layers, which works out, and I use a movie, I get a 2D graphic with colors.Its not the idea!I tried mesh. It is just for 2D matrix.plot3 doesnt create colors!
If there is a possibility how its done, that would help me a lot. I saw from other papers that it is somehow possible. They didnt add any code on it. Thanks in front for anyone with good ideas=)))
Accepted Answer
More Answers (3)
Sean de Wolski
on 25 Jan 2011
I really don't understand what you're aiming for. Do you want a colormap based on height?
If so you could use multiple calls to:
patch
with a varying color each time. The color could be based on the result from some function of:
[xx, yy, zz] = meshgrid(1:50);
Or you could make your movie in true color using the 4th dimension, also based on the above call to meshgrid.
doc immovie
Sean de Wolski
on 26 Jan 2011
What doesn't work about this?
[xx yy zz] = meshgrid(1:5)
scatter3(xx(:),yy(:),zz(:),20,sortrows(repmat([1 0 0; 0 0 1; 0 1 0; .5 0 .5; .5 .5 0],25,1)))
You have a numerical function zz(xx,yy).
3 Comments
Walter Roberson
on 26 Jan 2011
You don't use the value of the matrix, Sean, but you do put in a color table in the color field of scatter3(). Felix does not have a 3D color for each point: he has a single value for each point. Fortunately, the color parameter of scatter3() can also take an array of values that are interpolated into the color map. If that is being implied, though, then the only difference compared to my comment in the prior answer is the unimportant detail of the exact parameters provided to meshgrid()
Sean de Wolski
on 26 Jan 2011
Our answers crossed paths last night (Yours wasn't submitted when I started), Walter; otherwise I probably would've added to yours (since the biggest contribution was saying that what he has is a function). It's not totally clear still what Felix wants; it would be nice if he could show us a template from paint or something. Hopefully between all of these samples he'll be able to figure something out!
felix
on 27 Jan 2011
Categories
Find more on Color and Styling in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!