{"id":85,"date":"2012-09-11T18:51:31","date_gmt":"2012-09-11T18:51:31","guid":{"rendered":"http:\/\/dstarena.com\/blog\/?p=85"},"modified":"2017-01-04T09:33:54","modified_gmt":"2017-01-04T09:33:54","slug":"how-is-creating-and-displaying-a-graphical-user-interface-in-matlab","status":"publish","type":"post","link":"http:\/\/dstarena.com\/blog\/how-is-creating-and-displaying-a-graphical-user-interface-in-matlab\/","title":{"rendered":"How to Creating and Displaying a Graphical User Interface in MATLAB?"},"content":{"rendered":"<p><strong>Creating and Displaying a Graphical User Interface:<\/strong>&#8211;<\/p>\n<p>MATLAB GUIs are created using a tool called guide, the GUI Development\u00a0Environment. This <em>tool <\/em>allows a programmer to layout the GUI, selecting and aligning the GUI components to be placed in it. Once the components are in place, the programmer can edit their properties: name, color, size, font, text to display, and so forth. When guide saves the GUI, it creates a working program including skeleton functions that the programmer can modify to implement the behavior of the GUI. When a guide is executed, it creates the Layout Editor, shown in Figure 1.2. The large white area with grid lines is the <em>layout area, <\/em>where a programmer can layout the GUI. The Layout Editor window has a palate of GUI components along the left side of the layout area. A user can create any number of GUI components by first clicking on the desired component, and then dragging its outline in the layout area. The top of the window has a toolbar with a series of useful <em>tools <\/em>that allow the user to distribute and align GUI components, modify<\/p>\n<p>the properties of GUI components, add menus to GUIs, and so on. The basic steps<\/p>\n<p>required to create a MATLAB GUI are:<\/p>\n<p>1. Decide what elements are required for the GUI and what the function of each element will be. Make a rough layout of the components by hand on a piece of paper.<\/p>\n<p><strong>GUI\u00a0 WINDOW:<\/strong>&#8211;<\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>As an example of these steps, let&#8217;s consider a simple GUI that contains a single<\/p>\n<p>pushbutton and a single text string. Each time that the pushbutton is clicked, the text string will be updated to show the total number of clicks since the GUI started.<\/p>\n<p>Figure 1.2<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Graphical User Interface Components<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>This section summarizes the basic characteristics of common graphical user interface components. It describes how to create and use each component, as well as the types of events each component can generate. The components discussed in this section are:-<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u2022 Text Fields<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u2022 Edit Boxes<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u2022 Frames<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u2022 Pushbuttons<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u2022 Toggle Buttons<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u2022 Checkboxes<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u2022 Radio Buttons<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u2022 Popup Menus<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u2022 List Boxes<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u2022 Slide<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>The process of GUI require following steps:-<\/strong><\/p>\n<ul>\n<li>Initializing GUIDE (GUI Creator)<\/li>\n<li>Creating the Visual Aspect of the GUI<\/li>\n<li>Writing the Code for the GUI Callbacks<\/li>\n<li>Launching the GUI<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Initializing GUI (guide creator):-<\/strong><\/p>\n<p>First, open up MATLAB. Go to the command window and type in a guide.<\/p>\n<p>&nbsp;<\/p>\n<p>You should see the following screen appear. Choose the first option<\/p>\n<p><strong>Blank GUI (Default):-<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>GUI window appears:-<\/strong><\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>Creating a visual effect in GUI:-<\/strong><\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p>Add in all these components to the GUI by clicking on the icon and placing it onto the grid. At this point, your GUI should look similar to the figure below:<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Writing the code for the GUI call back:-<\/strong><\/p>\n<p>MATLAB automatically generates a .m file to go along with the figure that you just put together. The .m file is where we attach the appropriate code to the callback of each component. For the purposes of this tutorial, we are primarily concerned only with the <em>callback<\/em> functions. You don\u2019t have to worry about any of the other function types.<\/p>\n<p>Open up the .m file that was automatically generated when you saved your GUI. In the MATLAB editor, click on the icon, which will bring up a list of the functions within the .m file. Select <em>CALLBACK FOR EACH.<\/em><\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>Launching the GUI:-<\/strong><\/p>\n<p>The first way is through the GUIDE editor. Simply press the icon on the GUIDE editor.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating and Displaying a Graphical User Interface:&#8211; MATLAB GUIs are created using a tool called guide, the GUI Development\u00a0Environment. This tool allows a programmer to layout the GUI, selecting and aligning the GUI components to be placed in it. Once the components are in place, the programmer can edit their properties: name, color, size, font, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[217,213,214,212,215,216],"class_list":["post-85","post","type-post","status-publish","format-standard","hentry","category-matlab-2","tag-graphical-user-interface-matlab","tag-gui-callback","tag-guide-editors","tag-guide-function","tag-how-to-open-gui-window-in-matlab","tag-matlab-gui"],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/dstarena.com\/blog\/wp-json\/wp\/v2\/posts\/85","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/dstarena.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dstarena.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dstarena.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/dstarena.com\/blog\/wp-json\/wp\/v2\/comments?post=85"}],"version-history":[{"count":6,"href":"http:\/\/dstarena.com\/blog\/wp-json\/wp\/v2\/posts\/85\/revisions"}],"predecessor-version":[{"id":3661,"href":"http:\/\/dstarena.com\/blog\/wp-json\/wp\/v2\/posts\/85\/revisions\/3661"}],"wp:attachment":[{"href":"http:\/\/dstarena.com\/blog\/wp-json\/wp\/v2\/media?parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dstarena.com\/blog\/wp-json\/wp\/v2\/categories?post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dstarena.com\/blog\/wp-json\/wp\/v2\/tags?post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}<!-- WP Super Cache is installed but broken. The constant WPCACHEHOME must be set in the file wp-config.php and point at the WP Super Cache plugin directory. -->