Convert datetime into seperate columns
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Yoni Verhaegen -WE-1718-
le 25 Juil 2020
Modifié(e) : Brittany Scheid
le 25 Juil 2020
I have a CSV table that I load in Matlab and looks as follows (see below). I would like to separate the datetime column into separate values in the form of a double array, with 1 column for 'year', 1 column for 'month', and 1 column for 'day', something like:
2020 | 07 | 20
2020 | 07 | 20
The hour is not important. How can I do this? I attach the CSV file which can be loaded as:
seawatertemp_westhinder = readtable('seawatertemp_westhinder.csv');
0 commentaires
Réponse acceptée
Brittany Scheid
le 25 Juil 2020
Modifié(e) : Brittany Scheid
le 25 Juil 2020
In one line to get a double array:
[y,m,d] = ymd(seawatertemp_westhinder.times);
[y,m,d]
% Add to table
seawatertemp_westhinder.year= y
seawatertemp_westhinder.month = m
seawatertemp_westhinder.day= d
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Dates and Time dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!