Switch case (how to use for case insensitive string check)

This might be a dumb question, but i did not seem to find an answer.
I´m using switch statement like this,
switch str
case {'power','POWER','Power'.....}
is there any way for me write the string for comparison in the case statement only once, but which also covers all case combinations something like, strcmpi
Thanks in advance. Best Regards, Hss

답변 (2개)

Oleg Komarov
Oleg Komarov 2012년 2월 17일
switch lower(str)
case 'power'
end
Just lower the case of your control variable.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

태그

질문:

2012년 2월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by