switch

any good example of a 'switch' command , actually I need to make a code which when executed give me a option of selection and by pressing it it will execute that. Any Help in this .cheers

Respuestas (2)

Jan
Jan el 27 de Feb. de 2012

0 votos

It sound like you are not looking for switch, but for menu.

5 comentarios

Nasir Qazi
Nasir Qazi el 27 de Feb. de 2012
yes yes true , u r absolutely right , have some examples of menu.?
Nasir Qazi
Nasir Qazi el 27 de Feb. de 2012
in fact both , I need to show it in a proper display and when on a given choice , execute a different function
Jiro Doke
Jiro Doke el 27 de Feb. de 2012
Did you see the examples on the links that Jan provided (for switch and menu)?
Nasir Qazi
Nasir Qazi el 27 de Feb. de 2012
yes I did , but how can I combine both in one ?
Jiro Doke
Jiro Doke el 27 de Feb. de 2012
Just combined the first examples from each function...
choice = menu('Choose a color','Red','Blue','Green');
switch choice
case 1
disp('You pressed Red');
case 2
disp('You pressed Blue');
case 3
disp('You pressed Green');
otherwise
disp('You closed the window');
end

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 27 de Feb. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by