plotting data which extends several years

1 次查看(过去 30 天)
Consider the following example:
clear all
time_2007 = linspace(1+0.0417, 366, (366-1)*24);
time_2008 = linspace(1+0.0417, 367, (367-1)*24);
data_2007 = 1 + (20-1).*rand(8760,1);
data_2008 = 1 + (20-1).*rand(8784,1);
time = [time_2007,time_2008];
data = [data_2007',data_2008'];
plot(time,data);
Here time is given in decimal day. By plotting the time series the data currently overlap each other due to the similarity of the decimal days. How is it possible to plot this as a time series i.e. showing the data as it progresses from one year to the next so starting from January 2007 and finishing at December 2008. Please note that I am trying not to use the time series function provided.
I was considering converting the decimal days into julian days but was unsure on ow to make this more interpretable after plotting.

回答(1 个)

dk
dk 2012-4-10
Try one of these
time = [time_2007,time_2008+365];
plot(time,data);
or
time=[datenum('2007,1,1')+time_2007,datenum('2008,1,1')+time_2008];
figure,plot(time,data);
datetick('x','mmmyy')

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by