can a white space be included in a switch statement?

5 views (last 30 days)
good day! may I ask, can a ' ' or space be included in the switch statement.
For example
switch(var)
case 'Hello World'
end
is it possible? I really need to have two words for matching the expression var. thanks!

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 23 Feb 2013
Edited: Azzi Abdelmalek on 23 Feb 2013
Yes you can
a=' '
switch a
case ' '
d=10
case '1 2'
d=1000
end

Community Treasure Hunt

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

Start Hunting!