how to create a timetable from a datetime array and a matrix?
Mostrar comentarios más antiguos
I like to create a timetable from a datetime array and a matrix.
d = datetime('2021-01-01'):caldays(1):datetime('2021-01-10');
m = rand(10,5);
t = timetable(d', m)
The resulting table is as blow.
Time m
___________ _______________________________________________________
01-Jan-2021 0.95929 0.34998 0.28584 0.12991 0.60198
02-Jan-2021 0.54722 0.1966 0.7572 0.56882 0.26297
03-Jan-2021 0.13862 0.25108 0.75373 0.46939 0.65408
04-Jan-2021 0.14929 0.61604 0.38045 0.011902 0.68921
05-Jan-2021 0.25751 0.47329 0.56782 0.33712 0.74815
06-Jan-2021 0.84072 0.35166 0.075854 0.16218 0.45054
07-Jan-2021 0.25428 0.83083 0.05395 0.79428 0.083821
08-Jan-2021 0.81428 0.58526 0.5308 0.31122 0.22898
09-Jan-2021 0.24352 0.54972 0.77917 0.52853 0.91334
10-Jan-2021 0.92926 0.91719 0.93401 0.16565 0.15238
But, I like to create the resulting table with 5 columns as below.
Time A B C D E
___________ _______________________________________________________
01-Jan-2021 0.95929 0.34998 0.28584 0.12991 0.60198
02-Jan-2021 0.54722 0.1966 0.7572 0.56882 0.26297
03-Jan-2021 0.13862 0.25108 0.75373 0.46939 0.65408
04-Jan-2021 0.14929 0.61604 0.38045 0.011902 0.68921
05-Jan-2021 0.25751 0.47329 0.56782 0.33712 0.74815
06-Jan-2021 0.84072 0.35166 0.075854 0.16218 0.45054
07-Jan-2021 0.25428 0.83083 0.05395 0.79428 0.083821
08-Jan-2021 0.81428 0.58526 0.5308 0.31122 0.22898
09-Jan-2021 0.24352 0.54972 0.77917 0.52853 0.91334
10-Jan-2021 0.92926 0.91719 0.93401 0.16565 0.15238
So I tried the following code to give different names to each column, but it does not work.
t.Properties.VariableNames = {'A', 'B', 'C', 'D', 'E'}
Thank you very much for the help in advance.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!