Convert a Cell array to a timetable
50 次查看(过去 30 天)
显示 更早的评论
Hi, I have
A1=1x78995 cell array;
cell array {1x1800 double} {1x1800 double}.....
And A2 1x78995 cell with datetimes.
How can a create a timetable like
Time=timetable( [A2{1:78995}]',[78995x the first value of1800]'......,[78995x the last value of 1800])
so that I have a timetabel of 78995x1801 at the end.
Thank you.
1 个评论
采纳的回答
Steven Lord
2024-11-26,14:38
If you have a set of row vectors in a cell array
sampleCell = {1:10, 11:20, 21:30};
first to accomplish your stated goal you need to transpose them into column vectors.
sampleCellTransposed = cellfun(@transpose, sampleCell, UniformOutput=false);
Then pass them into the table or timetable function as a comma-separated list.
T = table(sampleCellTransposed{:})
To make a timetable, of course one of the inputs must contain time-based data. In this case since none of the cells in sampleCellTransposed do, I pass it in as the first input argument.
dt = datetime('today')+(0:9).';
TT = timetable(dt, sampleCellTransposed{:})
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!