dateticks

13 ビュー (過去 30 日間)
Suame New Road
Suame New Road 2012 年 5 月 10 日
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

回答 (1 件)

the cyclist
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')

カテゴリ

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