MATLAB: How to set datetick at 10 minute intervals when data starts at random times

data plottingdatetickif elseMATLABserial dates

I have several data sets that start at random times (e.g., 10:04:23, 08:27:59, etc). The time is in the serial date format which I use datetick to change to the mm/dd/yy HH:MM format . I am plotting experimental data versus time via a function. I want to plot the data every 10 minutes but I want the intervals to be multiples of 10. For example, if my data starts on Aug 1, 2013 10:04:23 I want my first tick mark to read 8/01/13 10:00 and show every 10 minutes until the end of the data. Because each data set starts at a different time I cannot just write a simple time subtraction function that would apply to all.
I am wondering if there is a way to get the time axis to plot every 10 minutes on a multiple of 10 minute using a loop or if/else statement. I do not want to have to go in and manually change the start tick each time.
Within my function I have the following where tenmin is 10 minutes as a serial date, start is the first time of the data and last is the end time of the data:
tenmin = 0.006944444496185;
set(gca,'XTick',[start:tenmin:last])
Thank you for any insight and help. -P. Wallace

Best Answer

tickstart = floor(start * 24 * 60 / 10) / (24 * 60 / 10);
now you can use tickstart:tenmin:last