App designer: How to determine answer using value from dropdown List
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Clemence Ndiaye
le 9 Avr 2022
Commenté : Clemence Ndiaye
le 9 Avr 2022
I've been trying to programm an app that estimates energy consumption in a household.
For a given appliances the inputs are:
- Number of selected appliances: dropdown list you can choose from. (variable "q1" in code)
- Energy consumption: dropdown list that lists usual engergy consumtion for the appliances (variable "ee1" in code), but also an edit field if you know the exact value (variable "e1" in code).
- Number of hours the appliance is used in a day: edit field (variable "n1" in code).
I've create the callbacks for the button "estimate" as such:

Explanation on Why i used The "if...else...end" : when the user inputs an exact value of the energy consumption of the appliance the answer will be calculated using that value. but if the edit field =0 than the value from the dropdown list is used.
These are the issues i am getting:
-When i put values after i run the program, the value that is calculates seems random and does not look like it was calculated using the values i've inserted, The answer is totally wrong.
-When i select a value for the energy usage from the dropdownlist this is the message that appears:

Please note this the first time i am using this program, my level is lower than that of a beginner. I would appreciate if the your answers were as basic as possible.
0 commentaires
Réponse acceptée
Image Analyst
le 9 Avr 2022
Not sure with App Designer (I'm still using GUIDE) but the Value property might be the index of the item selected, not the contents that you see displayed in the dropdown. At least if it's like GUIDE, we'd do this
selectedItem = app.ouchoisirlestimateionDropDown.Value; % 1, 2, 3, etc.
allItems = app.ouchoisirlestimateionDropDown.String; % The contents -- what the user sees displayed.
% Extract just the contents of the one single selected item:
q1 = allItems{selectedItem}
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Computational Geometry dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!