if option with weekend and date serial number

2 ビュー (過去 30 日間)
AA
AA 2017 年 11 月 28 日
回答済み: Walter Roberson 2017 年 11 月 28 日
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 Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by