- your timestamps are not in chronological order, the plot will show this too.
- converting to datetime has not made your fractional seconds disappear: the default 'format' simply does not show fractional seconds. Change the 'format' if you want to see them displayed.
turning date strings to overal minutes
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
yonatan ossia
le 1 Jan 2020
Commenté : yonatan ossia
le 2 Jan 2020
Hi, i have various Dat. files from which i calculate some variables, the files are named acoording to the date and time:
2019_12_31_17_43_31.39-Isd
2019_12_31_17_19_36.39-Ig
2019_12_31_16_55_41.38-Ig
2019_12_31_16_55_41.38-Isd
2020_1_1_12_7_5.13-Isd
where: filename = year_month_day_hour_min_sec. the problem is that the program doesnt do the standard YYYYMMDDHHMMSSSS depending on values (01 is given simply as 1)
i need to make a value-time plot for the variables, so i wanted to transform the overall date in to overal minutes starting from the lowest time.
any ideas or functions that could work?
0 commentaires
Réponse acceptée
Stephen23
le 1 Jan 2020
Modifié(e) : Stephen23
le 1 Jan 2020
>> C = {...
'2019_12_31_17_43_31.39-Isd'
'2019_12_31_17_19_36.39-Ig'
'2019_12_31_16_55_41.38-Ig'
'2019_12_31_16_55_41.38-Isd'
'2020_1_1_12_7_5.13-Isd'
};
>> D = regexp(C,'^\w+\.\w+','match','once');
>> T = datetime(D, 'inputFormat','yyyy_M_d_H_m_s.SS')
T =
31-Dec-2019 17:43:31
31-Dec-2019 17:19:36
31-Dec-2019 16:55:41
31-Dec-2019 16:55:41
01-Jan-2020 12:07:05
and you can plot the datetime object directly (no need to count minutes from some random epoch):
>> V = rand(1,numel(T));
>> plot(T,V)
Notes:
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!