- 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
How can you fix this question?
1 view (last 30 days)
Show older comments
Switch Today
case 'Friday'
disp ('Happy Friday')
case ['Saturday','Sunday']
disp ('YAY Weekend')
else
disp ('No Weekend')
end
0 Comments
Accepted Answer
the cyclist
on 3 Mar 2014
There are several small mistakes, all of which a careful reading of
doc switch
could have solved.
switch Today
case 'Friday'
disp ('Happy Friday')
case {'Saturday','Sunday'}
disp ('YAY Weekend')
otherwise
disp ('No Weekend')
end
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!