フィルターのクリア

How to store value of selected item in a drop down to a variable

20 ビュー (過去 30 日間)
Paul
Paul 2022 年 12 月 3 日
回答済み: Paul 2022 年 12 月 5 日
I am working on a live script and want to populate a drop down list with data from an Excel workbook, The data consists of two colums - names of acids and their pKa values. I can import the data as a table and from that can get column vectors. The drop down needs to display the names of the acids and their pKa values.
Am I right in thinking that it is not possible for the drop down to display two columns?
Assuming it is not possible, I am constructing a column vector containing the names of the acids with their pKa values in parentheses. I am doing this in a for ... end loop (see attached script) but is there a better/faster way of doing it?
The drop down is working nicely but I cannot change the width of the control (not the list) which looks like this . This is a potential deal breaker.
However, if I can overcome that problem, there is a further hurdle to clear. When the selection is changed I want to be able to store the pKa value of the selected item to a variable for use further down.
It does not seem possible, further down the script, to refer to the drop down or its selected value because the drop down does not have a name which can be used to reference it.

採用された回答

Paul
Paul 2022 年 12 月 5 日
There are three parts to this answer.
  1. The drop down can only contain one column so I put the pKa values in parentheses after the names of the acids.
  2. I cannot alter the width of the drop dow, so I just have to live with that
  3. Storing the pKa value is as easy as putting pKa = to the left of the drop down

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by