Dates from Excel Spreadsheet won't import into MATLAB
6 views (last 30 days)
Show older comments
Hi all, thanks for the answers to my previous questions.
I have an Excel 2007 file with a column of dates of the visual format 5/21/2011. When I right-click and click on Format cell, it shows that it is of type "date." I then have 3 columns of numbers. When I try both xlsread('name_of_file') or in MATLAB "Edit," then "Paste to Workspace," it only shows the 3 columns of numbers and doesn't even show the dates.
I also tried to copy JUST the dates and paste it into MATLAB and then try to combine the other info but when I try to paste the dates from within MATLAB to the file with the numbers I get the error message "numeric arrays cannot contain strings." It seems that when I can get the dates to enter MATLAB they enter as a string instead of a date number.
Would appreciate any help.
0 Comments
Answers (1)
Jan
on 28 Aug 2011
Are you able to import the dates as serial date numbers, e.g. by formatting them in Excel to this format? Then you can convert the numbers from Excel's to Matlab's serial date number format by adding 693962 (for Excel on PC, on Macs Microsoft decided to start 4 years later and you have to add 695422). See also X2MDATE.
2 Comments
Fangjun Jiang
on 28 Aug 2011
Should use datestr(). Please give a snip of the data you got in MATLAB. It's much easier to talk about if you give some examples.
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!