MATLAB: If option with weekend and date serial number

weekend date serial number

I have a date serial number x. If the number is a weekend then x+3, if the number is not a weekend then x +1. how can i put this as code?

Best Answer

output = x + 1 + 2 * isweekend( datetime(x, 'convertfrom', 'datenum') );
or
output = x + 1 + 2 * ismember(weekday(x), [1 7]);