Plot question: Monthly data on yearly axis
이전 댓글 표시
Hi all,
I would like to ask how is it possible to plot monthly data on an axis that displays years on the axis.
Many thanks!
댓글 수: 1
Matt Tearle
2011년 4월 9일
Can you elaborate on what format your data is in? Do you have a time series of monthly observations? Are they serial date numbers, or just integer values, or years with fractional parts, or what? An example would help.
답변 (3개)
Oleg Komarov
2011년 4월 9일
You were using datenum incorrectly:
startdate = datenum('31-01-2002','dd-mm-yyyy')
enddate = datenum('31-12-2010','dd-mm-yyyy')
dt = linspace(startdate,enddate,108);
data = rand(numel(dt),1);
plot(dt,data)
datetick('x','yyyy','keepticks')
Royi Avital
2011년 4월 9일
0 개 추천
If I'm guessing right what's your difficulty the fact that plot doesn't show "NaN" values should assist you.
Meaning, Pad your data to the 'x' length with "NaN".
John Smith
2011년 4월 9일
카테고리
도움말 센터 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!