Filter löschen
Filter löschen

Date Axis

4 Ansichten (letzte 30 Tage)
KKR
KKR am 8 Okt. 2011
Hello Everyone,
Hope all is well. I need some help regarding, setting up Dates on x-axis. I have about 195 data points, and of course, I would like only 10-15 dates to show up on axis, as labels. Here is what I have tried to do, but somehow it is not working.
startDate = datenum('01-01-1995');
endDate = datenum('12-31-2010');
numtick = round((endDate - startDate)/365);
xData = linspace(startDate,endDate,numtick);
hold on
grid on
set(gca,'XTick',xData)
set(gca,'XTickLabel',datestr(xData,12))
p1 = plot(winmeanav,'-r');
p2 = plot(spxnav,'.-g');
p3 = plot(sprnav,'-k');
title('Time Series plot of NAVs between 1/1/1995 and
12/31/2010')
xlabel('Number of Months passed since 1/1/1995')
ylabel('NAVs')
Please let me know, if any extra information is needed. Any help would be very appreciated.
Thanks,

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 8 Okt. 2011
In your linspace() use numtick+1 .
For example suppose there was a difference of 1 year, 365 days. The serial date difference would be 365, round(365/365) would be 1, and then your current code would try to represent that 1 year range as a single value whereas you want one for the beginning and one for the end.
Also, you might have to cellstr() around the datestr() call.
  1 Kommentar
KKR
KKR am 11 Okt. 2011
Thank you Walter.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

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

Community Treasure Hunt

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

Start Hunting!

Translated by