I have a MySQL table with over 6 million records, each with a epoch timestamp. I need to plot all the timestamps across time of day. In other words, I need to see how many timestamps are between 7am and 8am, 8am to 9am, etc – for all 24 hour blocks in day. I do not need them plotted by day of the week or month, just time in the day. Each timestamp is in UTC.
can someone help me?
You could use MySQL’s
FROM_UNIXTIMEfunction to get date strings from the database, and dump the results into a file, which you can subsequently read into MATLAB. Next, one of the ways to extract the time of day of each record is to use MATLAB’sdatevecfunction, to get each component of the date string seperately:For instance, if you read in the data as one long vector with date strings, you could apply
datevecto this vector, and subsequently grab the ‘hour column’ of the resulting matrix. Then, you can make a histogram of the counts using thehistorhistcfunctions, depending on whether you want to specify bin centers or bin edges. If you have an hour columnH, something likehist(H, 0:23)should work. Thehistcfunction might be a bit more natural for the nature of your data, but is slightly more involved; check the documentation.