plotting data extending one year

1 visualización (últimos 30 días)
Richard
Richard el 31 de Ag. de 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'.

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 31 de Ag. de 2012
Editada: Andrei Bobrov el 31 de Ag. de 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)))

Más respuestas (0)

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by