Menu function, MATLAB in Statistics

MENU Function:

The MATLAB also has a built-in function known as menu which will display a figure Window with push buttons for the choices. The very first string passed to the menu function is the heading, and the rest are labels which appear on the push buttons. The function returns the number of button which is pressed. For illustration,

>> mypick = menu('Pick a pizza', 'Shroom', 'Cheese', 'Sausage');

will display the Figure Window as shown in figure below and store the result of the user's button press in the variable mypick.

1482_menu function.png

There are three buttons, whose equivalent values are 1, 2, & 3. For illustration, if the user presses the Sausage button, then mypick would have the value 3:

>> mypick

mypick =

3

Note that the strings 'Shroom', 'Cheese', and 'Sausage' are merely labels on the buttons. The real value of the button press in this situation would be 1, 2, or 3.

A script which uses this menu function then would use either an if-else statement or a switch statement to take an action depends on the button pressed. For illustration, the script below simply prints which pizza to order, by using a switch statement.

236_menu function1.png

Here is an illustration of running this script and clicking the Sausage button:

>> pickpizza

Order a sausage pizza

Posted Date: 10/19/2012 3:27:54 AM | Location : United States







Related Discussions:- Menu function, Assignment Help, Ask Question on Menu function, Get Answer, Expert's Help, Menu function Discussions

Write discussion on Menu function
Your posts are moderated
Related Questions
Steps for input output functions - Lower level file: The steps involved are as shown below:  Open the file.  Read the file, write to the file, or append to the file.

#qYou will need to examine two of the nine sections of data: one section of qualitative data (choose either Gender or Position) one section of quantitative data (choose either Intr

WHILE Loops: The while statement is used as a conditional loop in MATLAB; it is used to repeat an action whenever ahead of the time it is not known how many times the action w

Working of Editor and debugger: Editor/Debugger, or commands can be typed from Command Window. For illustration, the dbstop command below will set a breakpoint in the fifth li

Illustration of Binary search: An illustration to search for the key of 91 in the vector is as shown below: The table below shows what will happen in each iteration of

Example of Median For the vector [1 4 5 9 12 33], the median is the average of the 5 & 9 in the middle: >> median([1 4 5 9 12 33]) ans =     7

Polynomials: Simple curves are polynomials of various degrees, or orders. The degree is the integer of the highest exponent in the expression. The illustrations are as follows

Operation on file: We concentrate first on the fgetl function that reads strings from the file one line at a time. The fgetl functions afford more control over how the data is

Illustration of Input in a for loop: In this illustration, the loop variable iv iterates through the values 1 through 3, therefore the action is repeated three times. The acti

Location of a rectangle - graphics objects: The location of a rectangle is [x y w h], where x and y are the coordinates of the lower left point, here w is the width, and h is