title: Matlab: Convert file date with milliseconds into Matlab time format
body: <p>I have some text files with dates of the form</p>
  <blockquote>
  <p>2015-09-08 14:38:03</p>
  <p>2015-09-08 14:38:03.1</p>
  <p>2015-09-08 14:38:03.2</p>
  </blockquote>
  <p>that I want to convert into Matlab date/time format. As you can see, the text strings have a different time format regarding the milliseconds. In the first case, no milliseconds are given; in the seconds case, milliseconds are given with one digit only. This gives a sampling rate of 20Hz for measuring data.</p>
  <p>So far, only</p>
  <blockquote>
  <p>x = datenum(file.dateColumn, 'yyyy-mm-dd HH:MM:SS');</p>
  </blockquote>
  <p>is working, but of course misses the milliseconds. A conversion like</p>
  <blockquote>
  <p>x = datenum(file.dateColumn, 'yyyy-mm-dd HH:MM:SS.FFF');</p>
  </blockquote>
  <p>does not work as the milliseconds are either zero (full seconds) or have one digit after the '.' delimiter. A workaround like</p>
  <blockquote>
  <p>x = datestr(file.dateColumn, 'yyyy-mm-dd HH:MM:SS.FFF');</p>
  <p>x = datenum(file.dateColumn, 'yyyy-mm-dd HH:MM:SS.FFF');</p>
  </blockquote>
  <p>i.e. converting the text string into a Matlab string (and giving it additional FFF/FF digits) and then converting that one into a date/time number works - but this is such time-cosuming that I cannot use it for my data. I have millions of time rows in different files.</p>
  <p>Do you have any ideas?</p>
  <p>Greetings, Arne</p>