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
回答(2 个)
Honglei Chen
2012-2-27
There are several examples in the documentation
doc switch
Jan
2012-2-27
0 个投票
5 个评论
Nasir Qazi
2012-2-27
Nasir Qazi
2012-2-27
Jiro Doke
2012-2-27
Did you see the examples on the links that Jan provided (for switch and menu)?
Nasir Qazi
2012-2-27
Jiro Doke
2012-2-27
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
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!