Plotting time in x-axis

2 visualizaciones (últimos 30 días)
Sergio
Sergio el 7 de Nov. de 2013
Editada: dpb el 8 de Nov. de 2013
Hi,
I'm trying to plot 2 hydrographs for comparison but I'm having problems with changing the time in the x axis to the format of Hour in the day like "DD HH:MM". The code I'm using to plot is shown below. I've tried datetick with no luck. Thank you for your help!
plot(dateus(z1:z2),Qusgs(z1:z2),'m');
hold on
plot(ns,Q,'g');
hold off
legend('USGS','SWMM')
title('Change in Width for Accotink Watershed Using Dulles Precipitation Data for Sept29-Oct2, 2010 Event')
xlabel('Time')
ylabel('Q')
saveas(h,sprintf('Width%d.png',x));
  3 comentarios
Sergio
Sergio el 7 de Nov. de 2013
Hi Azzi,
here is the actual data I'm plotting. Thanks!
dpb
dpb el 7 de Nov. de 2013
Editada: dpb el 8 de Nov. de 2013
OK, so still what/how does the dateus value relate to real time? You'll need to translate that to Matlab datenum as noted earlier to use builtin Matlab facilities. Otherwise, you can manually make labels but that's the harder solution it would seem.
ADDENDUM:
Matlab thinks 733779 is 6Jan2009 if assume a datenum -- is this correct? Excel thinks its 6Jan3909 owing to the difference in start dates.
Whatever it is, that's the basic starting point to get the offset from the Matlab datenum origin to match up to what these represent if they're not Matlab-consistent as is. If they are, then plot with them on the x-axis and as noted, used datetick to format the axis as desired.

Iniciar sesión para comentar.

Respuestas (1)

dpb
dpb el 7 de Nov. de 2013
You need the x-axis variables to be in Matlab serial datenums and then used datetick to format.
doc datenum % and friends
doc datetick

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by