Menu function, MATLAB in Statistics

Assignment Help:

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


Related Discussions:- Menu function

Roots function - polynomials, Roots function - Polynomials: The roots ...

Roots function - Polynomials: The roots function in MATLAB is used to find the roots of an equation represented by a polynomial. For illustration, for the mathematical functio

Location of a rectangle - graphics objects, Location of a rectangle - graph...

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

Combining nested for loops and the if statements, Combining Nested FOR Loop...

Combining Nested FOR Loops and the IF Statements: The statements inside a nested loop can be any of the valid statement, involving any selection statement. For e.g., there can

Run-time or execution-time error, Run-time or execution-time error: Th...

Run-time or execution-time error: The Run-time, or execution-time, errors are found whenever a script or function is executing. With most of the languages, an illustration of

Example of vectorizing, Example of Vectorizing: Likewise, for an opera...

Example of Vectorizing: Likewise, for an operation on a matrix, a nested loop would be needed; for illustration, supposing a matrix variable mat: [r c] = size(mat); for

Menu function, MENU Function: The MATLAB also has a built-in function ...

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

Polynomials, Polynomials: Simple curves are polynomials of various deg...

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

While loops, WHILE Loops: The while statement is used as a conditional...

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

Illustration of indexing, Illustration of Indexing: Though, rather tha...

Illustration of Indexing: Though, rather than of creating the index vector manually as shown here, the process to initialize the index vector is use to a sort function. The al

Execution of persistent variables, Execution of persistent variables: ...

Execution of persistent variables: The functions can also be called from the script or from the Command Window, as shown here. For illustration, the functions are called first

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd