title: matlab - calculate the 95 % interval around the mean
body: <p>If I have a vector of monthly-averaged values like</p>
  
  <pre><code>aa = [1,2,3,2,1,3,5,3,4,8,9,7;...
      11,12,3,21,1,3,15,3,4,8,19,7;...
      21,2,3,2,1,23,5,3,34,84,9,7]';
  </code></pre>
  
  <p>where each column refers to the monthly-averaged values from different locations and each row represents the month of year. I can calculate the average of all of the sites as:</p>
  
  <pre><code>mean_a = nanmean(aa,2);
  </code></pre>
  
  <p>and thus can plot the averages of these as:</p>
  
  <pre><code>plot(1:12, mean_a);
  </code></pre>
  
  <p>How would I now calculate the 95 % confidence interval around these mean values?</p>
  
  <p>Any advice would be appreciated.</p>
  
  <p>My attempt:</p>
  
  <p>Assuming a normal distribution:</p>
  
  <pre><code>aa = [1,2,3,2,1,3,5,3,4,8,9,7;...
      11,12,3,21,1,3,15,3,4,8,19,7;...
      21,2,3,2,1,23,5,3,34,84,9,7]';
  
  mean_a = nanmean(aa,2);
  sem = (nanstd(aa')./sqrt(size(aa,2))).*1.96;
  errorbar(1:12,mean_a,sem);
  </code></pre>