필터 지우기
필터 지우기

Switch case simple mistake

조회 수: 1 (최근 30일)
ddd ppp
ddd ppp 2017년 10월 8일
편집: Walter Roberson 2017년 10월 8일
Hi, why doesnt 'works' show when i run this? Is it because the case has to be the switch input?
inStr='d'
switch inStr
case inStr(1)=='d'
outStr='works'
otherwise
'error'
end

채택된 답변

Walter Roberson
Walter Roberson 2017년 10월 8일
case inStr(1)=='d' evaluates inStr(1)=='d', generating the value false or true. That value is then compared to inStr because of switch inStr, and is found to not equal to inStr.
switch inStr(1)
case 'd'

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by