Dates from Excel Spreadsheet won't import into MATLAB
이전 댓글 표시
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.
답변 (1개)
Jan
2011년 8월 28일
0 개 추천
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
Don
2011년 8월 28일
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.
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!