Dates from Excel Spreadsheet won't import into MATLAB
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Jan
2011-8-28
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 个评论
Fangjun Jiang
2011-8-28
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!