how to synchronize structures with date fields in text format
1 次查看(过去 30 天)
显示 更早的评论
I have a 31x1 cell array C. Each cell of C contains a structure of variable dimensions (41x1 to 50x1) but all structures have the same number of fields. Each structure has a ‘date’ field. The dates in each ‘date’ field are in text format.
I want to transform each structure in C into a timetable so I can synchronize them. I tried struct2table and then table2timetable but it does not work because the dates are not in datetime format. How do I change the format of the dates in the ‘date” field of each structure, so I can convert the structures in timetables and then synchronize them?
Thank you
0 个评论
采纳的回答
Walter Roberson
2020-3-28
dateinfo = cellfun(@(S) datetime({S.date}), C, 'uniform', 0);
TT = cellfun(@(S, T) table2timetable(struct2table(S), 'RowTimes', T), C, dateinfo);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!