필터 지우기
필터 지우기

How to increment a variable

조회 수: 4 (최근 30일)
Riven Yvet
Riven Yvet 2015년 12월 9일
답변: Walter Roberson 2015년 12월 9일
Hi. I have a code that outputs the given day for a specific date (ANY DATE). I first calculated the sum of the month, year and day in number keys then the results is to be divided by 7 which is then proposed to an if else statements. Now Imm running the code fine when I input any dates from March 2012 to jan 2016. My problem is, every four years, leap year happens so fhere is an increase in days IN FEBRUARY. My question is how do you increment this interms of adding one per for four years, and only adding that one to the february date? I know its an increment thing but i really dont know how. Thanks

답변 (1개)

Walter Roberson
Walter Roberson 2015년 12월 9일
year_is_leap_year = (YEAR >= 1583) & (YEAR < 4909) & (mod(YEAR,4) == 0) & ((mod(YEAR,400) == 0) | (mod(YEAR,100) ~= 0));
Unless, that is, you are calculating for England or any possession of England including USA, in which case the 1583 needs to be changed to 1753.
The 4909 year is the latest year by which there will need to be a correction because the current system has a year approximately 26 seconds too long.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by