How can I detect the third saturday of each month?

2 Ansichten (letzte 30 Tage)
Adriano
Adriano am 21 Feb. 2017
Kommentiert: Adriano am 22 Feb. 2017
Hello everyone! I have the follow vector of date-number:
734321 734328 734336 734342 734349 734356 734363 734371 734377 734384 734391 734399 734405 734412 734419 734427 734433 734440 734447 734454 734462 734468 734475 734482 734490 734495 734503 734510 734517 734525 734531 734538 734545
I need to remove from the array each dates (numbers) who aren't the third saturday of the month. How can I do? Many thanks!

Akzeptierte Antwort

Jan
Jan am 21 Feb. 2017
Bearbeitet: Jan am 21 Feb. 2017
d = [734321 734328 734336 734342 734349 734356 734363 734371 734377 ...
734384 734391 734399 734405 734412 734419 734427 734433 734440 ...
734447 734454 734462 734468 734475 734482 734490 734495 734503 ...
734510 734517 734525 734531 734538 734545];
dSaturday = d(weekday(d) == 7); % Saturdays only
dv = datevec(dSaturday);
dThird = d(dv(:, 3) >= 15 & dv(:, 3) <= 21);

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time 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!

Translated by