Filter löschen
Filter löschen

If I use the built in menu function, can I then use "switch" and call the "case" by the order it appears on the menu?

2 Ansichten (letzte 30 Tage)
choice = menu('Choose an option!','Set user name', 'Load data file');
switch choice
case 1
% Set user name
set_user_name();
case 2
% Load data file

Akzeptierte Antwort

Image Analyst
Image Analyst am 18 Nov. 2016
Of course? Why wouldn't you be able to? And it looks like you actually tried it so don't you already know the answer?
  2 Kommentare
Kyle Reagan
Kyle Reagan am 18 Nov. 2016
My menu has 11 options, so I haven't completed it yet. I was wondering if the numbers have to have an apostrophe around them or if it can just be free-standing. (e.g. 1 vs '1')
Image Analyst
Image Analyst am 18 Nov. 2016
No quotes. Just do it exactly like you had it. Anyway, it's easy enough to try both ways if you weren't sure.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by