How to Build a Simple Graphical User Interface in MATLAB

Matlab is a powerful mathematical tool for matrix calculations and almost any other mathematical function you need. Matlab also has the ability to form windows like applications with its programming language.

Steps

  1. Image titled Build a Simple Graphical User Interface in Matlab Step 1
    1
    Open the Matlab Program and wait for it to finish loading
  2. Image titled Build a Simple Graphical User Interface in Matlab Step 2
    2
    Click on "MATLAB" in the launch pad to expand the list and then double click on "GUIDE (GUI Builder)". If you cannot see the launch pad, click on view followed by launch pad. The GUI builder will appear
  3. Image titled Build a Simple Graphical User Interface in Matlab Step 3
    3
    Click on the "ok" button in the left hand side of the window. This will allow you to drag and drop a pushbutton.
  4. Image titled Build a Simple Graphical User Interface in Matlab Step 4
    4
    Move the mouse to somewhere on the grey area in the center of the window.
  5. Image titled Build a Simple Graphical User Interface in Matlab Step 5
    5
    Click once and hold down the button and drag your mouse until the square that this forms is of the size you'd like
  6. Image titled Build a Simple Graphical User Interface in Matlab Step 6
    6
    Release the mouse button and you will see your push button appear
  7. Image titled Build a Simple Graphical User Interface in Matlab Step 7
    7
    Double click on the pushbutton you just created. A property manager will pop up
  8. Image titled Build a Simple Graphical User Interface in Matlab Step 8
    8
    Locate the "string field" and click the area to the right of it and type "Say Hello". Also Change the Tag to "button"
  9. Image titled Build a Simple Graphical User Interface in Matlab Step 9
    9
    Find the button on the left labeled "txt" and follow the same step 8 again
  10. Image titled Build a Simple Graphical User Interface in Matlab Step 10
    10
    Now click on file then save to save your work. This will also pop up the code for your program.
  11. Image titled Build a Simple Graphical User Interface in Matlab Step 11
    11
    Locate the line of code in the code editor that says function varargout = pushbutton1_Callback(h, eventdata, handles, varargin). This is the callback function. Any code below this will be executed whenever the user pushes the button. Here we will make this change the text in the text box when the user clicks on the button
  12. 12
    Write set.

Sources and Citations

Article Info

Categories: Graphics