Using 'OR' operator with 'case' statement

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일

11 개 추천

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개)

카테고리

태그

아직 태그를 입력하지 않았습니다.

질문:

2019년 1월 29일

답변:

2019년 1월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by