title: MATLAB: Datetick at even monthly intervals
body: <p>I want to mark my time series at even monthly intervals from Jan 2008 to Jan 2011.</p>
  
  <p><strong>EDIT: The time series already has a time component in datenum format:</strong></p>
  
  <pre><code>733408 x1
  733410 x2
  etc...
  </code></pre>
  
  <p><strong>I apologize for not making this clear in my original statement of the question.</strong></p>
  
  <p>A straightforward twice-annually implementation becomes incredibly messy:</p>
  
  <pre><code>years = [2008 2008 2009 2009 2010 2010 2011];
  months = [1 7 1 7 1 7 1];
  days = ones(1,7);
  for k = 1:7
      dates(k) = datenum(years(k), months(k), days(k));
  end
  labels = datestr(dates,'mmm-yy');
  set(gca,'XTick',dates);
  set(gca,'XTickLabel',labels);
  </code></pre>
  
  <p>To expand this to monthly ticks:</p>
  
  <pre><code>years = [2008 ...repeat10times 2009 ...repeat10times 2010 ...repeat10times 2011]
  m = 1:11; months = repmat(m,1,3)
  days = ones(1:34)
  </code></pre>
  
  <p>There must be a simpler way!</p>