Your desired fbusdateweek function can be executed on one line, using only the weekday function to get the first Sunday of the week then busdate to get the next business day after that:
dn = 736942; % Date number for any day in a week Date = busdate(dn-weekday(dn)+1);
Note. busdate uses the holidays function by default to get all holidays and special days without a trend for the New York Stock Exchange. If necessary, you can use an alternative set of holidays for busdate as follows:
holidayArray = ...; % Some set of date numbers, vectors, or datetimes Date = busdate(dn-weekday(dn)+1, 1, holidayArray);
This way you can define a set of localized holidays.
source share