MATLAB: How can you fix this question

switch

Switch Today
case 'Friday'
disp ('Happy Friday')
case ['Saturday','Sunday']
disp ('YAY Weekend')
else
disp ('No Weekend')
end

Best Answer

There are several small mistakes, all of which a careful reading of
doc switch
could have solved.
  • MATLAB is case-sensitive, so you need to write "switch" not "Switch"
  • You need to enclose multiple cases in curly brackets, not square brackets
  • You need to use "otherwise", not "else", in a switch statement
switch Today
case 'Friday'
disp ('Happy Friday')
case {'Saturday','Sunday'}
disp ('YAY Weekend')
otherwise
disp ('No Weekend')
end