Borrar filtros
Borrar filtros

Plotting daily occurrence of events in a 3 year time span

5 visualizaciones (últimos 30 días)
btåla
btåla el 30 de En. de 2017
Comentada: btåla el 2 de Feb. de 2017
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.

Respuesta aceptada

Jayaram Theegala
Jayaram Theegala el 1 de Feb. de 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 comentario
btåla
btåla el 2 de Feb. de 2017
Hello Jayaram,
It was much easier than I thought. Anyway, thank you for the response.
Cheers,

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by