Using 'OR' operator with 'case' statement

68 ビュー (過去 30 日間)
Abdullah
Abdullah 2019 年 1 月 29 日
回答済み: Kevin Phung 2019 年 1 月 29 日
Is it good programming practice to use 'OR' operator with 'case' statement. I want to associate multiple values of 'switch' statement with each 'case' statement like below.
switch value
case 1|2|3
execute this
case 4|5|6
execute this
end

採用された回答

Kevin Phung
Kevin Phung 2019 年 1 月 29 日
This would be the proper way for using or:
switch value
case {1,2,3}
% execute this
case {4,5,6}
% execute this
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAutomated Driving Toolbox についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by