필터 지우기
필터 지우기

How to write case in simple way ?

조회 수: 1 (최근 30일)
Henry Buck
Henry Buck 2016년 3월 23일
댓글: Henry Buck 2016년 3월 27일
Hi,
Is there a simple/short way to write switch case ?
instead : case {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20} ... ... otherwise ...
something like case 1 to 20 or case {1:20} ?
Thanks,
Henry

채택된 답변

per isakson
per isakson 2016년 3월 24일
편집: per isakson 2016년 3월 24일
One way
>> cssm(12)
12
where
function cssm(jj)
switch jj
case num2cell([1:24])
disp( jj )
otherwise
disp('failed')
end
end
And
case num2cell([1:24])
may be replaced by
case num2cell(1:24)
in contemporary releases of Matlab
  댓글 수: 1
Henry Buck
Henry Buck 2016년 3월 27일
Great ! Thanks a lot.
Henry

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

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

Community Treasure Hunt

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

Start Hunting!

Translated by