Azzera filtri
Azzera filtri

converting excel datetimes in matlab

22 visualizzazioni (ultimi 30 giorni)
Sophia
Sophia il 17 Apr 2024
Modificato: Stephen23 il 17 Apr 2024
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 Commenti
Gyan Vaibhav
Gyan Vaibhav il 17 Apr 2024
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 il 17 Apr 2024
Modificato: Stephen23 il 17 Apr 2024
"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.

Accedi per commentare.

Risposte (0)

Tag

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by