Plotting time in x-axis

2 Ansichten (letzte 30 Tage)
Sergio
Sergio am 7 Nov. 2013
Bearbeitet: dpb am 8 Nov. 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 Kommentare
Sergio
Sergio am 7 Nov. 2013
Hi Azzi,
here is the actual data I'm plotting. Thanks!
dpb
dpb am 7 Nov. 2013
Bearbeitet: dpb am 8 Nov. 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

dpb
dpb am 7 Nov. 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

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by