Sunteți pe pagina 1din 9

I.

PROBLEM STATEMENT

Using the application MATLAB, what are the required parameters of the given
complex problems below? Solve using MATLABs GUI function.

Problem #1 Make an interactive program to solve the output of a voltage divider


circuit shown below. Enter the values of R1, R2, and input voltage by using the
edit box. Show the output voltage by pressing calculate.

Problem #2 Make a simple calculator using Matlab GUI by entering 2 numbers.


Clicking on the operations will display the result in the text box.
II. PROCEDURES (Includes results)

General Procedures

Step 1. Set up your GUI. After opening MATLAB, type guide and select the blank
GUI option.

Step 2. Go over the tools used in creating a GUI and add whatever is necessary to
your program.

Step 3. After completing the setup and coding, save file and run the program.
Procedures for Problem #1 (Refer to the problem statement)
STEP 1. Set up the GUI in the following manner.

STEP 2. Right click on the lower left Static Text object and select Inspect properties. Change the String
Property from Static Text to input voltage.
STEP 3. Right click on the Upper Static Text object and select Inspect properties. Change the
String Property from Static Text to R1.
STEP 4. Right click on the lower right Static Text object and select Inspect properties. Change
the String Property from Static Text to .
STEP 5. Right click on the Upper Right Static Text object and select Inspect properties.
Change the String Property from Static Text to Vout.
STEP 6. Right click on the lower left Edit Text object and select Inspect properties. Change
the Tag Property from Edit1 to vi.
STEP 7. Right click on the upper Edit Text object and select Inspect properties. Change the
Tag Property from Edit2 to r1.
STEP 8. Right click on the lower right Edit Text object and select Inspect properties. Change
the Tag Property from Edit3 to r2.
STEP 9. Right click on the upper right Edit Text object and select Inspect properties. Change
the Tag Property from Edit4 to vo.
STEP 10. Right click on thePushButton object and select Inspect properties. Change the String
Property from PushButton to calculate.

STEP 11. Right Click on the Calculate Button, view callback>>Callback, and add the following
code at the last part of the program.

STEP 12. Save and Run the program. On the edit box, enter your desired resistance R1and R2,and
input voltage and observe the output voltage.
Procedures for Problem #2 (Refer to the problem statement)

Step 1. Add a panel where all the components of the simple calculator will be placed.
Step 2. Add four (4) push buttons for the four operations (ADDITION, SUBTRACTION,
MULTIPLICATION and DIVISION). Label according to the operation and tag each push
button. Tags will be used in the callback option later.

Step 3. Create another panel beside the Operations panel. Refer to the picture shown below. The
panel below is composed of two static texts and three edit texts. The edit texts are used for
displaying the numerical values. Dont forget to tag each text.
Step 4. Right click the first push button (ADDITION) and select view callbacks then
callbacks. After selecting this, you will be redirected to the editor window. See the highlighted
part of the code.

Step 5. Below the highlighted portion is the part where you should place the codes for the simple
calculator to operate. Referring to the picture above, we get the values of n1 and n2. Since the
first push button that is being programmed is the ADDITION, therefore, c=a+b .

Step 6. Copy and paste the codes in the callbacks of the push buttons of the other three
operations while changing the formulas.
Step 7. Run the GUI program.

Step 8. Shown below is the result after running the program.

Step 9. Test each operation by placing values for the 1st and 2nd number.

Figure 1. For ADDITION


Figure 2. For SUBTRACTION

Figure 3. For MULTIPLICATION

Figure 4. For DIVISION


III. CONCLUSIONS AND LEARNING EXPERIENCES

In this experiment the class used a new function which is graphical user interface
or GUI. The callback is the main function that you write to make components, such as
buttons, sliders, or menus, respond to user input, such as button clicks, slider
movements, and menu item selections.

S-ar putea să vă placă și