How to Create a Plot with a years on x-Axis

2 ビュー (過去 30 日間)
devendra
devendra 2014 年 5 月 18 日
編集済み: devendra 2014 年 5 月 18 日
sir i want to plot years on x-axis.it mean want (2006 to 2013) on xtick(x-axis).please help me. thank you in advance.

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 5 月 18 日
編集済み: Azzi Abdelmalek 2014 年 5 月 18 日
Look at this example
t=0:0.01:10;
y=sin(t);
plot(t,y)
xl=get(gca,'xlim')
xt=linspace(xl(1),xl(2),2013-2006+1);
set(gca,'xtick',xt)
set(gca,'xticklabel',cellfun(@num2str,num2cell(2006:2013),'un',0))
  1 件のコメント
devendra
devendra 2014 年 5 月 18 日
編集済み: devendra 2014 年 5 月 18 日
sir when i am using xl=get(gca,'xlim')
xt=linspace(xl(1),xl(2),2013-2006+1);
set(gca,'xtick',xt)
set(gca,'xticklabel',cellfun(@num2str,num2cell(2006:2013),'un',0))
then in my plot only show years 2007 to 2013,2006 is not showing

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

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by