AIM: 1) Study and Implementation of Edit box in MATLAB GUI.
2) Implementation of Addition of Two numbers using two
edit boxes.
PROCEDURE:
1. For
opening GUI tool simply type following command in command window.
>> guide
|
Fig: 1
GUI menu bar with all Buttons
2. In
second step simply click over Edit box as mentioned in fig 1. Drag that button
in a empty space as mentioned in fig 2.
Fig: 2
GUI with a Edit box
3.
Next step is to change the properties of the Edit box. For this just double
click on Edit box this action will open property inspector. Property inspector
consists of various properties of the Edit box. You have to change background
color if necessary, font size, font weight, remember tag of the edit box or
keep tag as it is and finally you have to change the string of the edit box
from Edit Text to ‘0’ because you have to enter number here for doing various
operation. Our aim is to do addition of two numbers for this we require two
edit boxes, one pushbutton and one static text. Two edit boxes for entering two
numbers, pushbutton for doing addition of two numbers and text box for
displaying result of addition as shown in fig 3.
Fig: 3
GUI with a Edit box, Pushbutton and Static text
4. Now
right click on ADD button and open callback of that button. This action will
directly link in to m file as shown in following fig. 4
Syntax for get:
Var=get(handles.tag_of_the_editbox,’string’)
|
Syntax for set:
set(handles.tag_of_the_static_text,’string’,var)
|
Fig: 4
m file and respective code of project
5. In
above code ‘str2num’ will convert the content from string to number. Following fig
shows you final output.
Fig: 5
Final output Addition of two numbers with edit boxes.
No comments:
Post a Comment