title: How plot a 3-order tensor in MATLAB
body: <pre><code>a = zeros(100,100,100);
  distance = [1,21,41,61,81];
  for d = 1:5
      for i=distance(d): distance(d)+19
          for j=distance(d): distance(d)+19
              for k=distance(d): distance(d)+19
                  a(i,j,k) = 1;
              end
          end
      end
  end
  </code></pre>
  
  <p>The tensor <code>a</code> with size (100,100,100) and all element dominate the diagonal. </p>
  
  <p>How to visulize <code>a</code> it in <code>MATLAB</code> with zero is white color and one is black color.  I plot in MS office, this is what I want <a href="https://i.stack.imgur.com/tQupY.png" rel="nofollow noreferrer">Expected image</a></p>
  
  <p>For matrix case, we can visualize as follow</p>
  
  <pre><code>X = zeros(100,100);
  distance = [1,21,41,61,81];
  for d = 1:5
      for i=distance(d): distance(d)+19
          for j=distance(d): distance(d)+19
              X(i,j) = 1;
          end
      end
  end
  
  
  imagesc(a)
  im = imagesc(1-X)
  colormap(gray(256))
  </code></pre>
  
  <p>And the image is 
  <a href="https://i.stack.imgur.com/68VrW.png" rel="nofollow noreferrer">2D matrix visulize</a></p>
  
  <p>How to do a similar way for tensor?</p>
  
  <p>And how to visulize tensor with noise? like noise on matrix <a href="https://i.stack.imgur.com/aWLLs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aWLLs.png" alt="here"></a></p>