switch

4 Ansichten (letzte 30 Tage)
Nasir Qazi
Nasir Qazi am 27 Feb. 2012
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

Antworten (2)

Honglei Chen
Honglei Chen am 27 Feb. 2012
There are several examples in the documentation
doc switch

Jan
Jan am 27 Feb. 2012
It sound like you are not looking for switch, but for menu.
  5 Kommentare
Nasir Qazi
Nasir Qazi am 27 Feb. 2012
yes I did , but how can I combine both in one ?
Jiro Doke
Jiro Doke am 27 Feb. 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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Instrument Control Toolbox Supported Hardware finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by