How can you fix this question?

1 view (last 30 days)
Maryam
Maryam on 3 Mar 2014
Answered: the cyclist on 3 Mar 2014
Switch Today
case 'Friday'
disp ('Happy Friday')
case ['Saturday','Sunday']
disp ('YAY Weekend')
else
disp ('No Weekend')
end

Accepted Answer

the cyclist
the cyclist on 3 Mar 2014
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

More Answers (0)

Categories

Find more on Functions in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!