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

Sequential search, Sequential Search: A sequential search is completed...

Sequential Search: A sequential search is completed by looping through the vector element-by-element starting from the beginning, looking for the key. Usually the index of the

Core objects, Core Objects: The Core Objects in MATLAB are the very fu...

Core Objects: The Core Objects in MATLAB are the very fundamental graphics primitives. The description can be found under the MATLAB Help: Under the Contents tab, click the Ha

Types of errors, Types of errors: There are some various kinds of erro...

Types of errors: There are some various kinds of errors which can occur in a program, that fall into the categories of run-time errors, syntax errors, and logical errors. T

Tracing a error, Tracing: Sometimes, when a program has loops and/or s...

Tracing: Sometimes, when a program has loops and/or selection statements and is not running properly, it is helpful in the debugging process to know exactly which statements h

Rectangle - graphics objects, Rectangle - graphics objects: The other ...

Rectangle - graphics objects: The other core graphics object is the rectangle that can have curvature added to it (!!). Merely calling the function rectangle without any argum

Median, Median The median is defined only for a data set which has been...

Median The median is defined only for a data set which has been sorted first, that means that the values are in order. The median of a sorted set of data values (n) is defined

Function stubs, Function Stubs: The other common debugging method, whi...

Function Stubs: The other common debugging method, which is used when there is a script main program which calls many functions, is to use the function stubs. A function stub

Lower level file i/o functions, Lower Level File I/O Functions: Whenev...

Lower Level File I/O Functions: Whenever reading from data file, as long as the data in the file is "regular" the load function works-in another words, the similar type of dat

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

Mode, Mode The mode of a data set is the value which appears most often...

Mode The mode of a data set is the value which appears most often. The built-in function in a MATLAB for this is known as the mode. >> x = [9 10 10 9 8 7 3 10 9 8 5 10];

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