필터 지우기
필터 지우기

Loop through a matrix

조회 수: 1 (최근 30일)
Damith
Damith 2014년 4월 30일
댓글: dpb 2014년 4월 30일
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
Roger Stafford
Roger Stafford 2014년 4월 30일
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 2014년 4월 30일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Calendar에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by