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

Fopen function - file function, fopen function - file function: The fo...

fopen function - file function: The fopen opens the file for reading. The fscanf then reads each line one double and one character, and put each pair in individual columns in

Example of nested functions, Example of Nested functions: For illustra...

Example of Nested functions: For illustration, the function below computes and returns the volume of a cube. Three arguments are then passed to it, for the width and length of

Properties of the text box - graphics objects, Properties of the text box -...

Properties of the text box - graphics objects: By using get will show properties of the text box, the illustration is as shown below: >> get(thand)   BackgroundColor

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

Input in a while loop, Input in a While Loop: The script below repeats...

Input in a While Loop: The script below repeats the procedure of prompting a user, the reading in a positive number, and echo-printing it, as long as the user properly enters

Illustration of nested loops, Illustration of Nested loops: Running th...

Illustration of Nested loops: Running the script shows the output: >> printstars ***** ***** ***** The variable rows identifies the number of rows to print, and

Fscanf function - file function, fscanf function - file function: The ...

fscanf function - file function: The fscanf reads matrix variable mat columnwise from the file specified by fid. The 'format' involves conversion characters much similar to th

Bus311.., #qYou will need to examine two of the nine sections of data: one ...

#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

Data structure layers, Data structure layers: There are many layers in...

Data structure layers: There are many layers in this variable. For illustration,  cyls is the whole data structure, that is a vector of structs  cyls(1) is a separate

Example of sorting strings, Example of sorting strings: To sort a cell...

Example of sorting strings: To sort a cell array of strings, also the sort function is used. The illustration is as follows, >> engcellnames = {'Chemical','Mechanical',.

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