Extract values from a cell based on dates
Ältere Kommentare anzeigen
Hi all,
I have data in 6 separate cells (A, B, C, D, E, F), all which are 365x1. One of these cells (A) contains dates as 'datenum' for a whole 12 months. My question is how can I call/pull/extract data from these cells based on date requirements and get an average. i.e. all of the values on the 10th for each month.
Would it be best to use stack and place them all as a table? I don't have any code for this yet as I don't know where to begin.
7 Kommentare
jonas
am 7 Okt. 2018
I dont understand exactly what you mean, but I am certain you will want to use datetime and perhaps place the data in a timetable.
Walter Roberson
am 7 Okt. 2018
timetable and retime() perhaps.
Manuel Flores
am 8 Okt. 2018
ANKUR KUMAR
am 8 Okt. 2018
Please attach the .mat file for more clarification.
Guillaume
am 8 Okt. 2018
It sounds to me that you would be much better off changing tack and importing your data in a single table or better a timetable. This probably would be simpler as well than the import code you already have.
Once the data is in a table or timetable, averaging by day/month/year/whatever is just a one line operation (using either rowfun on a table or retime on a timetable).
Therefore, I'd recommend we focus on changing your import code. For that, an example of the excel files would be helpful. Normally, a single call to readtable is all that is needed to import excel files.
jonas
am 8 Okt. 2018
As was suggested several times already, what you want is a timetable and retime. If you want to calculate some statistics based on the "day of month", then I would suggest using the day of month as a grouping variable. This is easy if you first convert your data to datetime format, which you should do anyway.
Manuel Flores
am 8 Okt. 2018
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Data Type Identification finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!