title: Matlab draw fading squares
body: <p>I need to create a script in MATLAB that will look similar to this:</p>
  
  <p><img src="https://i.stack.imgur.com/jGtbg.jpg" alt="The shape I have to make"></p>
  
  <p>But the code I have is not working, and it is giving me the inverse, in that, the squares grow in size rather than shrink.</p>
  
  <pre><code>x = [0 0 2 2];
  y = [0 2 2 0];
  fill(x,y,'r');
  hold on
  for i = 1:10
  x = [(x(3)) (x(3)) (x(3)/2) (x(3)/2)];
  y = [(y(3)) (y(2)/2) (y(2)/2) (y(3))];
  fill(x,y,'r');
  end
  </code></pre>
  
  <p>Please provide an explanation along with the answer as I want to learn what I did wrong.</p>