Writing a Leap year function without using the leapyr function
古いコメントを表示
I'm needing a to write a function that takes in a start and end year, and that outputs the leap years in-between those 2 parameters. I feel like I have a good base, but I can't figure out how to include that a year is not a leap year if it is divisible by 100. I have 2 potential ideas as to how to approach the task, but This is what I have so far:
function [] = leapyears(startYear,endYear)
for x=startYear-1:4:endYear-1
fprintf('%i \n', x+1);
if mod(startYear,100)==0
%y=0;
%while y<startYear
%if mod(startYear, 4) == 0 && mod(startYear, 400)==0 && mod(startYear,100)==0
%for x=startYear-1:4:endYear-1
%fprintf('%i \n', x+1);
%end
%y=y+1
%end
end
2 件のコメント
KSSV
2018 年 2 月 21 日
You are allowed to use inbuilt function calendar ?
Camila Perez
2018 年 2 月 21 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!