title: Convert mm/dd/yyyy to a form usable for datenum MATLAB
body: <p>I want to convert a column of dates from a cell from the format mm/dd/yyyy (They come in the form 4/10/2007, or with double digit months, 10/10/2007) to yyyy-mm-dd, and plot it. So I need to turn mm/dd/yyyy into serial date number.</p>
  
  <p>When the date column is already in the form yyyy-mm-dd, the following code works:</p>
  
  <pre><code>DateString = PM25data(:,11); % Pull out dates
      formatIn = 'yyyy-mm-dd';
      x1 = datenum(DateString,formatIn); % Convert to datnum
  </code></pre>
  
  <p>However, since the date form here is mm/dd/yyyy (for example, 4/12/2007), I can't get the above format to work with the error</p>
  
  <pre><code>DATENUM failed.
  
  Caused by:
      Error using dtstr2dtnummx
      Failed on converting date string to
      date number.
  </code></pre>
  
  <p>I also tried this code:</p>
  
  <pre><code>DateString = PM25data(2:end,1);
      formatOut = 'yyyy-mm-dd';
      x4 = datenum(DateString, formatOut); % Convert to datnum
  </code></pre>
  
  <p>But it runs this error:</p>
  
  <pre><code>Cannot convert input into specified date
  string.
  DATENUM failed.
  </code></pre>
  
  <p>How can I get datenum to work in this case?</p>