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

14 Ansichten (letzte 30 Tage)
Paul
Paul am 3 Dez. 2022
Beantwortet: Paul am 5 Dez. 2022
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.

Akzeptierte Antwort

Paul
Paul am 5 Dez. 2022
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

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by