Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to load dates in matlab

  1. Dec 6, 2009 #1
    hi every one, I have a problem for load dates in matlab, I have 2488 dates
    in xls file and txt file but I can't make that matlab read the number as a dates? Does anybody know how to do it???
    for example I have this:
    2000 03 01
    2000 04 01
    2000 05 01
    2000 06 01

    And I want that matlab shows me


    please help me
  2. jcsd
  3. Dec 6, 2009 #2
    ++ Firstly, you need to convert string to date-type variable by using datenum.
    Ex: datenum('2000 03 01', 'yyyy dd mm')

    ++ Secondly, using datestr:
    Ex: datestr(time, 'mmmm dd, yyyy')

    Combining: datestr(datenum('2000 03 01', 'yyyy dd mm'), 'mmmm dd, yyyy')

    Hope this helps
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook