Plotting daily occurrence of events in a 3 year time span

2 views (last 30 days)
How can I plot the occurrence intensity ( nr. of events in days) on daily basis, given that I have datetime arrays that include events ranging in a time span of up to 3 year. I have used [Discret,E] = discretize(time_intensity,'month'); and then [Histcount,edges]=histcounts(Discret); and it works ( after changing the XTicks to show monthly periods ) to achieve my goal for monthly basis but I am not able to do it for daily occurrence. I would like to have a plot of such data where on the y-axis I have the nr. of events happened on each day and on the x-axis the time span ( i.e. from Oct. 2013 to Nov. 2016) which is my events period of observation.

Accepted Answer

Jayaram Theegala
Jayaram Theegala on 1 Feb 2017
Hello Basmir,
In order to plot the occurrence intensity on daily basis, you can set the 'duration' argument for "discretize" function to 'day' instead of 'month'. You may find the following MATLAB code useful to get started:
if true
time_intensity = datetime(2016, 1,randi(365,1000,1)); %you can use your values instead of this
%filter the dates within the required range
filtered_time_intensity = time_intensity(time_intensity>datetime('Oct-2013') & time_intensity<datetime('Nov-2016'));
[Discret,E] = discretize(filtered_time_intensity,'day');
%Calculating number of bins for "histcounts" function
number_of_days = max(Discret) - min(Discret) + 1;
[Histcount,edges]=histcounts(Discret, number_of_days);
end
I hope this helps.
  1 Comment
btåla
btåla on 2 Feb 2017
Hello Jayaram,
It was much easier than I thought. Anyway, thank you for the response.
Cheers,

Sign in to comment.

More Answers (0)

Categories

Find more on Geographic Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!