converting excel datetimes in matlab
조회 수: 3 (최근 30일)
이전 댓글 표시
I am wanting to calculate the mean temperature (and standard deviation) for each day in 'seasim_temp', when I do this there are missing datetimes in 'unique_dates' and so missing data when I plot this (see missing_data.fig). I believe there is a problem with the format of the datetimes going from excel to matlab. See excel_figure to see what the data actually looks like in excel.
It would be great to understand more about formatting datetimes as I often come across a problem with them!
댓글 수: 2
Gyan Vaibhav
2024년 4월 17일
Hi Sophia,
In the excel file there are timestamps such as 58:19.0, can you explain the format, and how are you linking these timestamps to specific dates?
Stephen23
2024년 4월 17일
편집: Stephen23
2024년 4월 17일
"I believe there is a problem with the format of the datetimes going from excel to matlab."
Like almost every other question on this forum related to Excel dates, there are problems with the Excel worksheet itself.
Column A actually contains a mixture of cells formatted as general/date and as number. The first of multiple format changes occurs between line 758 (general/date) and line 759 (number):
But the format change is not the cause of your problems, just a hint of them. At that point the dates stop being stored in the XML as serial date numbers (i.e. proper Excel dates) and start being stored as a shared string (i.e. text):
With each format change the saved data type also changes. Ugh. In any case, lets go and have a look at the shared string XML and see the first text "date" in all of its glory:
So what you perhaps think is a nice column of dates is in fact a confusion of Excel dates and text. Perhaps you expect READTABLE to automagically import data using the philosophy import what I want, not what I give you. Users often do.
The best solution would be to fix the dates in that spreadsheet so that they are actually stored as dates and not just as text that look like dates because they have some pretty numbers in them. Looking like a date is not the same thing as being a date.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!