using switch, case and comparing strings
이전 댓글 표시
I am using a function with varargin that imports strings and numbers but the first input is always a string. based off what it says, using switch and case, I want the function to do something different. So if for example, str = char(varargin{1}) = 'hot dog' and I had
switch str
case str == 'hot dog'
case str == 'burger'
When I do this I get an error, what am I doing wrong
댓글 수: 2
str = varargin{1} = 'hot dog'
is illegal syntax and the SWITCH construct is missing any action statements in the cases plus isn't closed.
A properly formed SWITCH construct will work just fine with string or character variables; it will have an issue with a cellstr() argument unless you take care to dereference it.
We need to see the actual function to debug, not just bits and pieces.
Keith Holmlund
2018년 6월 21일
편집: Keith Holmlund
2018년 6월 21일
채택된 답변
추가 답변 (1개)
belhassan haj mansour
2019년 1월 9일
편집: belhassan haj mansour
2019년 1월 9일
0 개 추천
HELLO
im trying to control a rocker switch with another one in app designer, for example i have rockerswitch1 in the position 'off' and rockerswitch2 also in position 'off' . what i need is when i put rockerswitch1 in position 'on', the rockerswitch 2 become in the position 'on' too but i can't find the right function to do so
CAN ANYONE HELP ME WITH THIS PLEASE ?
댓글 수: 2
Walter Roberson
2019년 1월 9일
Please create a new Question for this .
belhassan haj mansour
2019년 1월 9일
done
카테고리
도움말 센터 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!