Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to carry logical function using 'menu' function in matlab?

Tags:

matlab

For the case as stated below,

a=3; b=4; c=5;
k = menu ('choose','a','b','c');

If the user select a how can I assign a value for it and do a logical loop? For example,

if 'a'; x=a;
else if 'b'; x=b;
else if 'c'; x=c;
end

Then I can continue my calculation using the value of x assigned. For example,

w=x+5
like image 345
green Avatar asked Sep 09 '26 22:09

green


1 Answers

k is the number of the user's choice. In your case:

switch (k) 
    case 1
       x = a;
    case 2
       x = b;
    case 3
       x = c;
    otherwise
       fprintf(1, 'do not know what to do - user closed menu w/o selection\n');
end
like image 187
Shai Avatar answered Sep 12 '26 18:09

Shai