plotting data extending one year
1 view (last 30 days)
Show older comments
In the following example I have a data set that extends over a section of two years.
time = datenum('2008-04-17 02:00'):datenum('2009-11-24 12:27');
dateV = datevec(time);
for i = 1:length(time);
DOY(i) = time(i) - datenum(dateV(i,1),0,0);
end
data = rand(length(time),1);
plot(time,data);
In this example I have calculated the day of year from the Julian date, but I cannot plot the data against day of year because the day of year will be the same for both years (if that makes sense). So, I have plotted the data against Julian date and would like to know of a way to alter the x axis to show the day of year calculated in 'DOY'.
0 Comments
Accepted Answer
Andrei Bobrov
on 31 Aug 2012
Edited: Andrei Bobrov
on 31 Aug 2012
try this is code
t = datenum('2008-04-17 02:00'):datenum('2009-11-24 12:27');
data = randi(150,numel(t),1);
DOY = t(:) - datenum(year(t(:)),0,1);
plot(t,data);
set(gca,'XTick',floor(t(1:50:end))','XTickLabel',floor(DOY(1:50:end)))
0 Comments
More Answers (0)
See Also
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!