Filter löschen
Filter löschen

plotting data extending one year

1 Ansicht (letzte 30 Tage)
Richard
Richard am 31 Aug. 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'.

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 31 Aug. 2012
Bearbeitet: Andrei Bobrov am 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)))

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by