MATLAB Answers

AA
0

if option with weekend and date serial number

Asked by AA
on 28 Nov 2017
Latest activity Answered by Walter Roberson
on 28 Nov 2017
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?

  0 Comments

Sign in to comment.

1 Answer

Answer by Walter Roberson
on 28 Nov 2017
 Accepted Answer

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

  0 Comments

Sign in to comment.