Borrar filtros
Borrar filtros

Loop through a matrix

1 visualización (últimos 30 días)
Damith
Damith el 30 de Abr. de 2014
Comentada: dpb el 30 de Abr. de 2014
hi,
I have a 3652500 x 2 matrix. That is reprsenting days of the years from 3000 to 12999 years (total 10000 years of data) of data . Once every 4 years there will be a leap year (i.e. 366 days). So I need to arrange yearly data like this [365 x 10000]. Can somebody help me with this?
Thanks.
  2 comentarios
Roger Stafford
Roger Stafford el 30 de Abr. de 2014
You seem to be forgetting that we use the Gregorian calendar. Here is a paragraph from a Wikipedia article on the subject: "Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400. For example, the years 1700, 1800, and 1900 are not leap years, but the year 2000 is."
dpb
dpb el 30 de Abr. de 2014
This sounds (other than the English) suspiciously like an earlier posting but you may find the isLeapYear logic function I provided earlier of use if not...
isLeapYear=(eomday(Y,2)==29); % logical vector T for Y==leap year
To use, build a year vector Y to go along with your daily data as
Y = [datenum(3000,1,1):datenum(12999,12,31)]';
The above does presume the Matlab datenum functions are ok for such extended ranges; I've not looked to see if they document the upper bound or not.
You can with the result of the above simply reshape the leap year years w/ 365 day/yr and obviously the logical negation of the result will provide the years w/ 366 day/yr.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Calendar 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