Divide histogram bins by time

Hello
So I have processed data and want to present it as frequency over time. I used datenum to get timevectors but I don't know how to chose the binwidth to encompass one month since month is irregular. The code below does plot it in time but I am not sure how the values like "737287" referes to a particular date. Dividing a year by 12 would also be sufficient as it is not very important which month it is but I have failed in this as well. The starting/end dates is not static either as more data will come.
Any help would me much appreciated.
Thank you in advance.
TimeNS = datenum(NotScaled(:,3), 'dd-mm-yyyy')
h1 = histogram(Time)
datetick('x','dd-mm-yyyy')

1 comentario

Steven Lord
Steven Lord el 23 de Jun. de 2021
Can you show a small (say half a dozen to a dozen) lines of your data so we can see the format in which it is stored? Can you also explain, in the context of that small data set, what (roughly) you want the plot to look like? Having a concrete example may make it easier to know what functions to suggest.

Iniciar sesión para comentar.

Respuestas (2)

Star Strider
Star Strider el 23 de Jun. de 2021

0 votos

I am not certain what the data are, however a histogram may not be appropriate. Instead, counting the data between two dates or averaging them using a timetable and the retime function may do what you want.
Since you are using datenum and datetick, you may not have these functions. If so, there are alternate approaches, such as combining unique and accumarray that would work instead.

1 comentario

Star Strider
Star Strider el 23 de Jun. de 2021
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Iniciar sesión para comentar.

Måns Lundberg
Måns Lundberg el 23 de Jun. de 2021

0 votos

Thank you, that was just the direction I needed!
Yeah that's my bad, forgot to mention the data set, they are binary with simply yes and no.

Preguntada:

el 23 de Jun. de 2021

Comentada:

el 23 de Jun. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by