Extract values from a cell based on dates
이전 댓글 표시
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
jonas
2018년 10월 7일
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
2018년 10월 7일
timetable and retime() perhaps.
Manuel Flores
2018년 10월 8일
ANKUR KUMAR
2018년 10월 8일
Please attach the .mat file for more clarification.
Guillaume
2018년 10월 8일
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
2018년 10월 8일
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
2018년 10월 8일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!