フィルターのクリア

Date Axis

4 ビュー (過去 30 日間)
KKR
KKR 2011 年 10 月 8 日
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,

採用された回答

Walter Roberson
Walter Roberson 2011 年 10 月 8 日
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 件のコメント
KKR
KKR 2011 年 10 月 11 日
Thank you Walter.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by