I want to visualize a three-dimensional array just like cubic lattice using MATLAB.
I have read How to plot 3D grid (cube) in Matlab, and Simple cubic lattice using three-dimensional array
If element in the array is only 0 and 1, I know how to use a three-dimensional array to draw a simple cubic lattice, the small cube has the same size.
However, Now I have a three-dimensional array like this,
cube(:,:,1) =
1 0 1
0 1 1
2 1 0
cube(:,:,2) =
0 0 1
1 5 1
0 1 0
cube(:,:,3) =
1 1 1
0 1 1
2 0 1
The array cube have value except 0 and 1. I want to visualize the array like cubic lattice, in which cube(:,:,1) denotes the first floor of the cubic lattice,
cube(:,:,2) denotes the second floor, and
cube(:,:,3) the third floor.
The value 0 denotes nothing, while value 1 denotes a small blue cube.
Value greater than 1 denotes sphere, the diameter of sphere varies according to the value.
The desired result is something like this:
Visualization of a three-dimensional array, 1 denotes a small green cube,0 denotes nothing,Value greater than 1 denotes white sphere, the diameter of sphere varies according to the value.
To explain my question more clear, show one visualization of two-dimensional array
1 denotes a small black sphere,0 denotes nothing,Value greater than 1 denotes white sphere, the diameter of sphere varies according to the value.
The desired effect drawing
it is Ok, when side length of cube is 1
when set side length as 2, drawCube([ix,iy,iz],2,Royal_Blue). The problem occurs, cubes is overlapping,