I have an array of values in the datetime format. Each value represent an event happening at the specified date and time. How can I plot event frequency in events per day, events per month, etc?
I already managed to plot events per hour of the day using histogram(mydata.Hour)
Thank you for your answers!
EDIT: some precisions after the first answer below:
yes, that's what I'm doing already using histogram and data.Hour. However, what I want to do is compute the average number of event per day, and plotting that all along the time period my events are.
here is a working example:
% generating 500 random events
dates = datetime(now-1000*rand(500,1),'convertfrom','datenum');
figure;
edges = -0.5:23.5;
histogram(dates.Hour,edges)
title('Events per hours of the day')
xlim ([-0.5 23.5])
ax1 = gca;
ax1.XTick = 0:2:23;
ax1.XTickLabel = {'Midnight','2','4','6','8','10','Noon','14','16','18','20','22'};
ax1.XTickLabelRotation = 45;
figure;
daynumber = weekday(dates);
histogram(daynumber)
title('Events per days of the week')
ax2 = gca;
ax2.XTick = [1:7];
ax2.XTickLabel = {'Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'};
ax2.XTickLabelRotation = 45;