Using a drop down menu in an App.

7 Ansichten (letzte 30 Tage)
Dan Green
Dan Green am 14 Dez. 2019
Kommentiert: Image Analyst am 17 Dez. 2019
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.

Akzeptierte Antwort

Image Analyst
Image Analyst am 14 Dez. 2019
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 Kommentare
Dan Green
Dan Green am 14 Dez. 2019
Thanks - worked like a charm
Image Analyst
Image Analyst am 17 Dez. 2019
You're welcome. Can you then "Accept this answer"? Thanks in advance.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Dan Green
Dan Green am 17 Dez. 2019
Thanks for the answer. it worked well.

Kategorien

Mehr zu Debugging and Analysis finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by