3d point colouring - 21 by 21 by 21 matrix

Hi,
I have a matrix 21 by 21 by 21. I need to do a "field plot" of this matrix, in which the matrix index defines the position & the value of the matrix element defines the point colour.
Any suggestions how to do this?
Thanks in advance.
Regards,

2 Comments

You could provide a 2x2x2 or 3x3x3 example to better explain what you want.
Suppose
x1 = -2:0.2:2;
x2 = -2:0.25:2;
x3 = -2:0.16:2;
[X1,X2,X3] = ndgrid(x1,x2,x3);
z = X2.*exp(-X1.^2 -X2.^2 -X3.^2);
Here for every z there is a corresponding (X1,X2,X3) & I want a plot with points on the grid coloured according to the value of z.

Sign in to comment.

 Accepted Answer

What about something like slice?
doc slice

6 Comments

Thanks for suggesting slice, I'll take help from this one:
% Define 3D data
[x,y,z] = meshgrid(linspace(-1,1,30));
v = x.^2 + y.^2 + z.^2;
% Define the slice plane
[xi, yi] = meshgrid(linspace(-1,1,50));
zi = xi;
% Slice it
slice(x,y,z,v,xi,yi,zi);
I get errors like "size of Z & A should be same" when I use scatter3.
Basically I need to plot a journal bearing parameter like Parasitic torque as the radial clearance, load & r.p.m. varies.
I have vectors for these three. Maybe I'll have to meshgrid these into arrays?
That error must be in scatter3 (or have you overwritten the builtin slice?) The above doesn't even call scatter3.
Maybe you could find a picture on google images, a free journal paper, or similar that resembles what you're looking for?
%%
x1 = -2:0.2:2;
x2 = -2:0.25:2;
x3 = -2:0.16:2;
[X1,X2,X3] = meshgrid(x1,x2,x3);
z = X2.*exp(-X1.^2 -X2.^2 -X3.^2);
slice(X1,X2,X3,z,[-1.5 0 1.5],0.8,[-1 0 1])
Thanks a lot, actually I sort of resolved the problem myself when I found a function "isosurface". Was going through an ebook & there various volume visualization functions were given.
I can now plot several isosurfaces with ishold = 1 & put a colorbar.
I think slice too is a good alternative.
Don't do it that way Calculate the isosurface once and then plot it with patch(). patch allows for fancy colors and edges/transparencies etc. and the isosurface calculation is computationally expensive so you don't want to do it more times than necessary.
doc isosurface
doc patch
Thanks for the suggestion, will try to use patch() & see the results.

Sign in to comment.

More Answers (1)

You may need a true volume visualization program like Avizo: http://www.vsg3d.com/avizo/overview. MATLAB can't do anywhere near what Avizo (and similar programs) can do.

1 Comment

Applied for a trial version of Avizo, will see how it goes.

Sign in to comment.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!