create menu with input
31 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hey all,
I have been trying to create menu with input command, I wanna the menu displays choices as buttons in a dialog box depends on how many element number I added
For example I wanna my output to be as the following
x=input('enter elments number' :) % which as an example =3
then
output = menu('Choose a element number','1 ','2 ','3')
I wanna do it automatically so if x=input('enter elments number' :) % which as an example =4
output = menu('Choose a element number','1 ','2 ','3','4')
Can anyone help ?
Thanks,
~
0 commentaires
Réponses (2)
Fangjun Jiang
le 29 Jan 2020
x=5;
xx=string(1:x);
menu('choose',xx(:))
4 commentaires
Fangjun Jiang
le 29 Jan 2020
menu() returns the index number so you konw which button the user clicked. To get different data based on this input, you need to do it afterwards in your program.
Ali Tawfik
le 30 Jan 2020
1 commentaire
Fangjun Jiang
le 30 Jan 2020
Modifié(e) : Fangjun Jiang
le 30 Jan 2020
What is "for menu(1)", "menu(2)"? There is no such syntax. I could only guess this is what you want.
f=[10, 200, 3000];
selection=menu('choose','1','2','3');
output=f(selection)
Voir également
Catégories
En savoir plus sur Matrix Indexing 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!