MATLAB: How to separate daily historical data into groups based on month and day not year

datemodespreadsheetdatastoretalltable

I started with a spreadsheet containing daily historical data of reservoir measurements. I used spreadsheetDatastore then made it into a tall table with just my dates and reservoir elevation. I would like to now separate the data based on month and day not year, in order to find the mode for a specific day throughout the years. ex. mode for elevation on October 2nd from 1983-2016 is … For the final product, I'd like to have a list of modes for every day. Any help on how to go about this would be great.

Best Answer

mde=grpstats(tbl.elev,day(tbl.date),@mode);
where
tbl is your table with fields .date and .elev. date is a datetime variable class and grpstats assumes you have the Statistics Toolbox.
Missing the Toolbox, use accumarray with a little more verbosity to establish the index array into which to accumulate.
ADDENDUM/ERRATUM
The above groups by day irrespective of month; there will be 31 values. To do by month and day, have to use both as grouping variables which requires adding both as variables--
tbl.mon=month(tbl.date); % add month and day
tbl.day=day(tbl.date); % individually to table
mde=grpstats(tbl.elev,{tbl.mon,tbl.day},@mode);
The peculiar syntax is using cell array for the grouping variables if there is more than a single one. The above will yield 365/366 values depending on whether is a leap year included or not...
ADDENDUM 2
You can dispense with the addition of the extra variables to the table; that was a case of newbie with grouping variables on my part as of yet, too, and somewhat confusing documentation descriptions combined with limited (and too simple) examples...the following works as well (which should have been obvious to me earlier but took a while before it dawneth upon me finally... :) )
mde=grpstats(tbl.elev,{month(tbl.date),day(tbl.date)},@mode);