How do I let a user choose what variable they want to assign a value to?
31 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Edward Tomanek
il 27 Dic 2018
Commentato: Stephen23
il 27 Dic 2018
I am making a program where I would like it to display a list of variable names (already created inside the program) and then let the user decide which one variable they want to assign a value to (either by typing the name of the variable or by typing in some pre-set command) and then input the value to be assigned to that variable.
(To give some background this is for a unit converter program where the user would, for instance, type "feet" and then e.g. "3" and it would return what 3 feet is in metres, inches, miles, yards etc; or they could type "metres" and then e.g. "5" and it would return this value in feed, inches etc).
1 Commento
Stephen23
il 27 Dic 2018
Letting the user dynamically select a variable name would not be a good approach:
There are plenty of much better approaches to writing a unit converter, just search File Exchange:
Risposta accettata
Image Analyst
il 27 Dic 2018
Modificato: Image Analyst
il 27 Dic 2018
I would put those variable names into a drop down list (what Mathworks calls a popup).
Then the user can select one, and in the popup callback, you can execute the proper code for that selection using a switch or if/else block.
Or perhaps less user friendly, you could use the menu() function and execute the appropriate code for whatever button number they clicked on.
0 Commenti
Più risposte (1)
madhan ravi
il 27 Dic 2018
Modificato: madhan ravi
il 27 Dic 2018
There's already one requires symbolic math toolbox :
0 Commenti
Vedere anche
Categorie
Scopri di più su Live Scripts and Functions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!