setting dateticks on a plot axis
Show older comments
I have two months' worth of timeseries data, recorded at 5 minute intervals. They start and end at strange times, eg April 7th, 13:55 to May 28, 17:35. I have an array of the dates (as strings, but have a numerical datenum too), and I want to place a tick and label at midday every second day. I'm struggling to understand how to do this using xTick because the first and last ticks aren't evenly spaced.
Answers (1)
Star Strider
on 3 Oct 2012
You seem to know everything you need to about 'XTick' and the rest, so it seems to me all you need are the appropriate datenum vectors.
Does this generate them the way you want?
datelimits = datenum([2012 04 07 13 55 00; 2012 05 28 17 35 00])
datediff = diff(datelimits);
startdate = floor(datelimits(1));
startdate = addtodate(startdate, 12, 'hour');
for k1 = 1:2:ceil(datediff)+1
dateloc(k1,:) = addtodate(startdate, k1-1, 'day');
end
dateloc(2:2:end) = [];
checkdates = [dateloc datevec(dateloc)]
The dateloc variable contains datenum representations. The checkdates variable is there to be sure it works as you want it to. The checkdates matrix of datevec dates is:
2012 04 07 12 00 00
2012 04 09 12 00 00
.
.
.
2012 05 29 12 00 00
in 2-day steps.
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!