title: MATLAB fill area between lines
body: <p>I'm trying to do something similar to what's outlined in this post:
  <a href="https://stackoverflow.com/questions/6245626/matlab-filling-in-the-area-between-two-sets-of-data-lines-in-one-figure">MATLAB, Filling in the area between two sets of data, lines in one figure</a>
  but running into a roadblock.  I'm trying to shade the area of a graph that represents the mean +/- standard deviation.  The variable definitions are a bit complicated but it boils down to this code, and when plotted without shading, I get the screenshot below:  </p>
  
  <pre><code>x = linspace(0, 100, 101)';    
  mean = torqueRnormMean(:,1);
  meanPlusSTD = torqueRnormMean(:,1) + torqueRnormStd(:,1);
  meanMinusSTD = torqueRnormMean(:,1) - torqueRnormStd(:,1);
  plot(x, mean, 'k', 'LineWidth', 2)
  plot(x, meanPlusSTD, 'k--')
  plot(x, meanMinusSTD, 'k--')
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/GtZU6.jpg" alt="mean and std"></p>
  
  <p>But when I try to implement shading just on the lower half of the graph (between mean and meanMinusSTD) by adding the code below, I get a plot that looks like this:</p>
  
  <pre><code>fill( [x fliplr(x)],  [mean fliplr(meanMinusSTD)], 'y', 'LineStyle','--');
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/jN84V.jpg" alt="shaded"></p>
  
  <p>It's obviously not shading the correct area of the graph, and new near-horizontal lines are being created close to 0 that are messing with the shading.</p>
  
  <p>Any thoughts?  I'm stumped.</p>