How to create input dialog box with drop down menu...????
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have the following table
Input A B
X32 27 4
X46 39 5
X60 59 7
X74 87 9
X88 131 12
X102 194 16
For this table, I want to create input dialog box with a drop-down menu.
Suppose I select X60 from the drop-down menu as an input value, then it should give the output values of A and B as 59 and 7 respectively.
0 commentaires
Réponses (2)
Image Analyst
le 17 Juil 2016
First you have to put column 1 of the table into the popup. I'm assuming you know how to do that. If not, I think it's something like this:
C = table2cell(T) % Convert table to cell array
handles.popup1.String = C{:, 1};
Though perhaps you don't need to convert to a cell array first now.
Then you need to get the index they selected from the popup and use that to get the other two numbers from the table. Something like (untested)
selectedIndex = handles.popup1.Value; % A number
A = T{selectedIndex, 2};
B = T{selectedIndex, 3};
You can do that from any callback you want since all callbacks have access to all uicontrols.
0 commentaires
Maruti B Patil
le 17 Juil 2016
Modifié(e) : Walter Roberson
le 17 Juil 2016
4 commentaires
Image Analyst
le 17 Juil 2016
You forgot to include the error message. Please include ALL of it, not just a part of it. Namely, I can't see your line of code that throws the error and I know that the line of code is included in the full error message. You must include ALL the red text if we are to debug it.
Walter Roberson
le 17 Juil 2016
I speculate that somewhere in your code, you overwrote handles.popup1 with something else. For example it is not uncommon for people to try something like
handles.popup1 = get(handles.popup1, 'Value');
under the thought that they are recording a copy of the value under the name popup1 and that MATLAB will know that when handles.popup1 is used in the context that requires a handle that MATLAB will know to refer to the handle instead of to the copy of the value that was saved under the same name.
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!