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 CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by