필터 지우기
필터 지우기

converting excel datetimes in matlab

조회 수: 3 (최근 30일)
Sophia
Sophia 2024년 4월 17일
편집: Stephen23 2024년 4월 17일
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
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
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 CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by