Help in visualizing four-dimensional data.

7 views (last 30 days)
Cailen on 2 Nov 2011
Commented: Tanguy on 16 Sep 2020
I am relatively unskilled in MATLAB, but I have an idea I would like to implement in MATLAB and I'm hitting a roadblock.
Basically, I am trying to come up with a visualization scheme for data created from three independent variables. For one, a plot would suffice, and for two, a surface would work, but I would like to create a visualization as follows for three independent variables:
I would like to create three independent axes, and at each point in that coordinate system, an equation of those three variables will be evaluated. This means every point in a typical three-space region will have a value associated with it. I then want to color-code each value based on what range it falls into. Then, I want to display this block of colors. In the end, the final visualization would be a massive cube, and various-colored regions of the cube would represent the value of the function at that particular (x,y,z) triple. In theory, one could then use this as a visualization of a three-variable function. One could look up each x,y, and z value independently, find its location on the cube, and look at the color of the value at that point to determine the value of the function for that triple.
That is the basic idea, and I would then like to be able to rescale the cube and "zoom in" on one particular region of it and have the colormapping also rescale.
The scenario I am imagining is this: The color-cube for a function is created. From observation of this color-cube, one particular region of the cube is identified as having a value within a desirable range. The user can then "zoom in" on that region, and the new "zoomed in" region will have the colormapping redone, allowing the user to identify the most desirable region out of that subregion. This is repeated ad infinitum until a suitable range of x,y,z variables is found that yield the desired value.
I am able to generate slices of the cube and display them individually using a basic "image" function, but I would like to display all of these slices together as one solid cube. Is there a way I can do this?
  1 Comment
Tanguy on 16 Sep 2020
You can use imtool3D to display your cube (3D-matrix)
tool = imtool3D(cube)
It features colormaps, pixel value on mouse over, zoom in/out with mouse control (middle click)
You can also see all your slice in one using
tool.montage = True;
Hope that helps!

Sign in to comment.

Answers (4)

Micah on 2 Nov 2011
I am also not an expert, but had to do this once. He is what worked for me, but it is inefficient.
hold on
for i=-10:10
for j=-10:10
for k=-10:10
Also use options
for best results. I also played around with the coloring, but just kept it in the range 0-1 (see below).
So I am just plotting each of my (x,y,z) values as (i,j,k) in a for loop, so making just that many individual plots. Then each plot is colored according to my fourth variable (here it is m). The function was x^2-2y^2+3z^2.
Remember, matlab can only handle colors between 0 and 1, so the +200 and /600 are normalizing values
The minimum of my function on the range -10:10 is -200, so I added 200 to get it it zero.
The maximum of my function was 400, so I added 400+200 and normalized to 600.
This plots well, but is hard to look at. I only graphed values from -10 to 10, so remember that when plotting as well.
  1 Comment
Cailen on 2 Nov 2011
Thanks! I'm thinking this will work for me. I haven't had a chance to test it yet. The "plot3" function was what was missing for me. I didn't know how to plot three axes independently (which I'm assuming is what plot3 does).

Sign in to comment.

Kelly Kearney
Kelly Kearney on 2 Nov 2011
Perhaps the slice function could help?

Walter Roberson
Walter Roberson on 2 Nov 2011
Basically, to do voxel operations, you are going to need to work with either patch() or mesh() (and I'm not as sure about mesh())
There is a voxel visualization MATLAB File Exchange contribution which might be of assistance.
I do not know why Mathworks has not put in its own voxel routines.
  1 Comment
Cailen on 2 Nov 2011
And now I know what a voxel is! I had seen that term in doing some basic research on my own, but I assumed it was a plugin or something (maybe because I'd seen it incorrectly capitalized a few times). But, upon looking it up, I will be able to understand some of my prior research a lot better, too.
I have seen a lot of work with patch, mesh, and isosurface in the stuff I've seen elsewhere online, so now that I understand it better I'll stand a fighting chance. Thanks!

Sign in to comment.

Patrick Kalita
Patrick Kalita on 3 Nov 2011
This series of videos discuses most of the functions used in MATLAB for visualizing functions of three variables:
Watching those will give you an idea of what is possible.

Community Treasure Hunt

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

Start Hunting!

Translated by