binary vector that consists of a zero for normal years and a 1 for a leap year
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Jakub
am 1 Jan. 2023
Bearbeitet: Star Strider
am 1 Jan. 2023
I need to create a vector that consists of a binary vector that consists of a zero for normal years and a 1 for a leap year, with some data i already have. How would i do this?
4 Kommentare
John D'Errico
am 1 Jan. 2023
Bearbeitet: John D'Errico
am 1 Jan. 2023
@Jakub Reemmber that we don't know at all what skills you have. But when you ask a question that seems simple, we must assume you know nothing about MATLAB.
Do you know how to compute the year, for each date?
Do you know the formula to identify a leap year, given the numbered year? How would you use that with the mod function, for example, to identify leap years?
Akzeptierte Antwort
Star Strider
am 1 Jan. 2023
Bearbeitet: Star Strider
am 1 Jan. 2023
YearVct = 1950:2050;
Lv = eomday(YearVct,2) == 29 % Create Logical Vector
LeapYears = YearVct(Lv) % Leap Years
LeapYearsMtx = buffer(LeapYears,5)
EDIT — (1 Jan 2023 at 17:15)
.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Calendar finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!