Effacer les filtres
Effacer les filtres

plotting data extending one year

1 vue (au cours des 30 derniers jours)
Richard
Richard le 31 Août 2012
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'.

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 31 Août 2012
Modifié(e) : Andrei Bobrov le 31 Août 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)))

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by