find groups in datetime vector by date

9 visualizaciones (últimos 30 días)
Senne Van Minnebruggen
Senne Van Minnebruggen el 22 de Mayo de 2020
Comentada: Senne Van Minnebruggen el 22 de Mayo de 2020
I am trying to find groups by date (dd/MM/yyyy) in a datetime vector (dd/MM/yyyy HH:mm:ss).
Herefor i tried changing the datetime format to dd/MM/yyyy and then use the findgroups function. But then each element in the datetime vector is identified as a single group. Next i tried to use g = findgroups(day(Datetimevector)). But then it is grouped by day of the month which is not the desired outcome.
How can i find groups by date in my datetime vector?

Respuesta aceptada

Rik
Rik el 22 de Mayo de 2020
Editada: Rik el 22 de Mayo de 2020
Datetimevector=datetime([2020 2020 2020],[02 02 10],[3 3 4],[10 11 12],[0 0 0],[0 0 0]);
rounded_to_day=datetime(year(Datetimevector),month(Datetimevector),day(Datetimevector));
g = findgroups(rounded_to_day);
Or use the older representation datenum:
rounded_to_day=floor(datenum(Datetimevector));
g = findgroups(rounded_to_day);

Más respuestas (0)

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by