if option with weekend and date serial number

1 次查看(过去 30 天)
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?

采纳的回答

Walter Roberson
Walter Roberson 2017-11-28
output = x + 1 + 2 * isweekend( datetime(x, 'convertfrom', 'datenum') );
or
output = x + 1 + 2 * ismember(weekday(x), [1 7]);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Holidays / Seasons 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by