How to create a table with a timedate
10 次查看(过去 30 天)
显示 更早的评论
I am trying to create table like with a column which shows the date from 2022-6-1 to 2022-9-26, and the row shows the time at 21h, 24h,3h,6h,9h,12h,15h,18h like the excel I draw below.
Here is my code, but it doesn't works fine
dates = datetime('2022-06-01'):days(1):datetime('2022-09-26');
times = {'21h', '24h', '3h', '6h', '9h', '12h', '15h', '18h'};
table_data = zeros(length(dates), length(times));
T = array2table(table_data, 'RowNames', times, 'ColumnNames', string(dates));
0 个评论
采纳的回答
Star Strider
2023-4-6
编辑:Star Strider
2023-4-6
Try this —
dates = datetime('2022-06-01'):days(1):datetime('2022-09-26');
times = {'21h', '24h', '3h', '6h', '9h', '12h', '15h', '18h'};
varTypes = {'double' 'double' 'double' 'double' 'double' 'double' 'double' 'double'}; % Change This As Necessary
T = table('Size',[numel(dates),numel(times)], 'VariableTypes',varTypes, 'VariableNames',times, 'RowNames',cellstr(dates.'))
.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calendar 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!