dateticks
조회 수: 13 (최근 30일)
이전 댓글 표시
Please I have a two year water level data(2009-2010). The water level was taken every two days, meaninig that I have 365 observations which were plotted in days but the duration for the work was 730 days. I would like to use dateticks on the X-axis for the my Kalman Filter model. I would like the X-axis to read like this: jan-09 to dec-10. please how should I go about it. Thank you.
Atta-Darkwa
댓글 수: 0
답변 (1개)
the cyclist
2012년 5월 10일
Here is some code that will do what I think you want.
Monthly labels are very mashed on top of each other, so I did quarterly instead. But I left in the code (commented out) for monthly.
% Make up the days
d1 = datenum('jan-1-2009');
d2 = datenum('dec-31-2010');
dailyDates = d1:d2;
% Identify where the ticks are
% Use this instead for quarterly date ticks
dayVec = ones(1,8);
monthVec = [1,4,7,10,1,4,7,10];
yearVec = [2009*ones(1,4),2010*ones(1,4)];
tickLocations = datenum(yearVec,monthVec,dayVec);
% % Use this instead for monthly date ticks
% dayVec = ones(1,24);
% monthVec = [1:12,1:12];
% yearVec = [2009*ones(1,12),2010*ones(1,12)];
%
% tickLocations = datenum(yearVec,monthVec,dayVec);
% Make up the data
xvec = randn(1,numel(dailyDates));
% Plot the data (with specified tick labels)
figure
plot(dailyDates,xvec)
axis tight
set(gca,'XTick',tickLocations)
datetick('x','mmm-yy','keepticks','keeplimits')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!