MATLAB: How to detect the third saturday of each month

dates datenum day

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!

Best Answer

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);