title: Visualize a three-dimensional array like cubic lattice using MATLAB
body: <p>I want to visualize a three-dimensional array just like cubic lattice using MATLAB.</p>
  
  <p>I have read <a href="https://stackoverflow.com/questions/7309188/how-to-plot-3d-grid-cube-in-matlab">How to plot 3D grid (cube) in Matlab</a>, and <a href="https://stackoverflow.com/questions/26644918/simple-cubic-lattice-using-three-dimensional-array">Simple cubic lattice using three-dimensional array</a></p>
  
  <p>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.     </p>
  
  <p>However, Now I have a three-dimensional array like this,</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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, </p>
  
  <pre><code> cube(:,:,2) denotes the second floor, and 
   cube(:,:,3) the third floor.
  </code></pre>
  
  <p>The value 0 denotes nothing, while value 1 denotes a small blue cube. </p>
  
  <p>Value greater than 1 denotes sphere, the diameter of sphere varies according to the value.
       The desired result is something like this: <img src="https://i.stack.imgur.com/kNqzp.png" alt="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."></p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>To explain my question more clear, show one visualization of two-dimensional array</p>
  
  <p><img src="https://i.stack.imgur.com/BB1s7.png" alt="enter image description here"></p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p><img src="https://i.stack.imgur.com/RW81x.jpg" alt="The desired  effect drawing"> The desired  effect drawing   </p>
  
  <p><img src="https://i.stack.imgur.com/y6Rt4.png" alt="enter image description here">
    it is Ok, when side length of cube is 1 </p>
  
  <p><img src="https://i.stack.imgur.com/pBPPT.png" alt="enter image description here">
    when set side length as 2, drawCube([ix,iy,iz],2,Royal_Blue). The problem occurs, cubes is overlapping, </p>