Switch case (how to use for case insensitive string check)
24 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (2 件)
Oleg Komarov
2012 年 2 月 17 日
switch lower(str)
case 'power'
end
Just lower the case of your control variable.
0 件のコメント
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!