How to count number of days within datetime array
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Louise Wilson
le 8 Juil 2020
Commenté : Louise Wilson
le 9 Juil 2020
I have a timetable which spans a year. The intervals between the datetimes varies from one minute to ten minutes. I am interested in finding out how many days contain any data at all. I tried using histogram but this returns an empty bin on days in which there was no data collected, and so conflates days where there was data collected but the values were 0, and data where there was no data collected.
numberdays=histogram(timetable.DateTime,'BinMethod','day');
This seems like it should be simple but I am sorry I can't figure it out!
0 commentaires
Réponse acceptée
Kanupriya Singh
le 9 Juil 2020
Since your previous attempts are returning you empty data for days that are not in your datetime array, you could calculate the number of days that have any data by using this function-
nnz(x)
This will return you the number of non-zero elements in the array.
2 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Timetables 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!