Also, I need to code to work for different excel sheets with different sets of dates/times. So it needs to recognize different dates but not specific ones. Needs to work on a general basis.
Create new matrix by date/time
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have an excel sheet that contains a column of dates and a column of times. Also, each day is designated by its own header (I have attached the sheet to this question). I want to be able to extract each day of data and put it into its own matrix (without any of the headers). Any recommendations on the best way to accomplish this?
Réponses (2)
Nikhil Negi
le 31 Mai 2018
Hello Samantha,
but since you have headers for each date, what you can do is read the xls file as table and search for the string 'Date' by lopping over 1st column of the table and save its index and then search for the string 'Date' again and save its index and extract the data from between these two indices. you can do that over and over and get the data between different dates.
0 commentaires
Peter Perkins
le 4 Juin 2018
The answer depends on what version of MATLAB you have. In recent versions, if you use readtable, that date column in the spreadsheet will be read in as a datetime variable in the table. The time column will propbably be read in as text.
To convert to durations, use this utility:
and then (assuming you want the date and time combined) just add the durations to the datetimes. Something like
t = readtable('Dat3eTimeData.xls');
t.Time = text2duration(t.Time);
t.DateTime = t.Date + t.Time
0 commentaires
Voir également
Catégories
En savoir plus sur Dates and Time dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!