Lecture 10

Lecture 10 - 14:440:127 Introduction to Computers for...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
14:440:127– Introduction to Computers for Engineers Notes for Lecture 10 Rutgers University, Fall 2009 Instructor- Blase E. Ur 1 Menus Rather than using the input statement, you can use Matlab to create a graphical menu, allowing the user to click on their selection. The example below creates a menu and then uses switch case to identify which option was chosen. Note that you must set the menu command equal to a variable, just as you did with the input statement. The first input argument to the menu function is the text displayed on the top of the menu. All of the subsequent arguments are the choices, which are strings separated by commas. The menu function returns an integer indicating which option was chosen. food = menu(’Welcome to White Castle, may I take your order?’, ’Cheeseburger’,’Chicken Rings’,’Mr. Pibb and Red Vines’,’Ok’); switch food case 1 disp(’Good call on the cheeseburger.’) case 2 disp(’Chicken comes in ring form?’) case 3 disp(’Crazy delicious!’) case 4 disp(’Yo momma’’s so fat, she went to White Castle. ..’) disp(’. ..looked at the menu. .. and said OK’); end 2 GUIs- Graphical User Interfaces To make a GUI (graphical user interface) in Matlab, type guide in the workspace. The GUI editor will pop up. Choose ”Blank GUI”. You should see a grid, along with a bunch of buttons on the left. You can click and drag these buttons onto the grid, and you’ll be making your interface. First, you design the aesthetics of your interface. Then, click on the green ”play button” to the top right of the GUIDE editor and you’ll program all of the logic behind the interface. After programming the logic behind the interface, you’ll see that you’ve saved both a .fig and a .m file. You need both of these files to make your GUI work! Also, if you want to edit the interface for your GUI after program- ming part of it, type guide in the workspace and choose the ”open existing GUI” tab. Note that GUIs aren’t really covered in your book. Instead, you should check out the following web tutorial, from which I took part of this lecture (and followed much of the same terminology): www.blinkdagger.com/matlab/matlab- gui-graphical-user-interface-tutorial-for-beginners 2.1 Properties of Objects Each time you drag another button/text/thing into your interface when using GUIDE , you create a new ”object.” An object can be a clickable button, an editable text box, a static (unchanging) text box, a graph, radio buttons, or all sorts of fun, exciting, and glamorous things. Each ”object” has a number of properties that define its appearance. You can change these properties by double clicking an object. A window like the following will open: 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
You’ll notice that the names of the properties are on the left, and the values are on the right. You can use this property inspector to change the appearance of the properties. Here are some of the most important properties: Tag is the name of the object. The
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

Lecture 10 - 14:440:127 Introduction to Computers for...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online