フィルターのクリア

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 Center および File ExchangeWeb Services についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by