Using a drop down menu in an App.

조회 수: 7 (최근 30일)
Dan Green
Dan Green 2019년 12월 14일
댓글: Image Analyst 2019년 12월 17일
I tried to use the App tool - the drop down menu. I asked for the .Value in the code view and printed it in the Command line. All that was fine. However when I tried to route the execution using the value: if val == 'name' where name was the value I got errors. I thought the value was a text string, so I do not see how that causes an error. Can you tell me how to use the drop down menu Value properly? I looked in the documentation, but could not find an example of using the drop down. Thanks, in advance.

채택된 답변

Image Analyst
Image Analyst 2019년 12월 14일
To compare strings, use strcmp(), strcmpi(), or contains() depending on how you want to do the comparison. If you use == it will give you an array of true or false values for whether each character matches or not then you'd have to use all() to see if they all match. Plus that doesn't work if they have different lengths. It's better to use strcmpi()
theyMatch = strcmpi(val, name);
  댓글 수: 2
Dan Green
Dan Green 2019년 12월 14일
Thanks - worked like a charm
Image Analyst
Image Analyst 2019년 12월 17일
You're welcome. Can you then "Accept this answer"? Thanks in advance.

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

추가 답변 (1개)

Dan Green
Dan Green 2019년 12월 17일
Thanks for the answer. it worked well.

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by