Problem with dropdown itemdata propiety

1 回表示 (過去 30 日間)
AngelRF64
AngelRF64 2019 年 8 月 12 日
コメント済み: AngelRF64 2019 年 8 月 12 日
I have a dropdown, with some items, and I want that when I select a item, the value returned will not be the item in characters, I want value to be a number associated with the item. I saw in MatLab documentation that itemdata need to be a 1-by-n numeric array.
Say this items: {a,b,c,d}
And say this itemdata: [1 20 300 4000], I understand that this is a numeric matrix right?
When I select for example b, matlab returns a 1x2 charater matrix containing '2' and '0'. I want instead of return this, return the matrix element as a number.
I'm not doing this by code, just with the component editor of matlab app designer.
Any one can help me please?

採用された回答

Adam Danz
Adam Danz 2019 年 8 月 12 日
編集済み: Adam Danz 2019 年 8 月 12 日
If you're using ItemData, the "Value" property will return the ItemData associated with your selection and it will be in the form of a string. Use str2double() to convert it to numeric.
Value = str2double(app.DropDown.Value);
  1 件のコメント
AngelRF64
AngelRF64 2019 年 8 月 12 日
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by