Divide histogram bins by time
12 views (last 30 days)
Show older comments
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 Comment
Steven Lord
on 23 Jun 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.
Answers (2)
Star Strider
on 23 Jun 2021
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 Comment
Star Strider
on 23 Jun 2021
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
See Also
Categories
Find more on Dates and Time 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!