Plot time-of day histogram for array of datetimes

20 views (last 30 days)
dormant
dormant on 1 Oct 2025 at 18:46
Commented: dpb ongeveer 17 uur ago
How do I create a histogram for an array of datetimes showing the counts of times of day from 00:00 to 24:00. I'd like the bin width to be variable between 1 to 60 minutes.

Accepted Answer

dpb
dpb on 1 Oct 2025 at 19:01
With datetimes, use the duration class for times of day..
  6 Comments
dormant
dormant ongeveer 18 uur ago
Thanks for the help. you pointed me the right way.
dpb
dpb ongeveer 17 uur ago
No problem -- I should have recalled the timeofday function; subtracting the base datetime for each day is what it does. Seems like maybe when the datetime class was first introduced it wasn't yet there, maybe, is why I fixated on using the duration class; I don't recall precisely. I do remember there being an Answers Q? quite a long time ago about creating some specialized plots that the poster had initially done with datenum required recasting; maybe that recollection got me sidetracked.
Anyways, glad you looked in more depth on your own...

Sign in to comment.

More Answers (0)

Categories

Find more on Data Distribution Plots in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!