Workshop 3 - Procedural Programming & Loop Statement
Workshop 3 - Procedural Programming & Loop Statement
Workshop 3 - Procedural Programming & Loop Statement
WORKSHOP GUIDE
MATLAB software
III. PROCEDURE:
Problem. You are given three resistors connected in series. Write a MATLAB script to
calculate the total resistance in the circuit. The values of the resistors are provided in
the script.
Instruction:
Problem. Create a function that calculates the power dissipated by a resistor given the
voltage across the resistor and its resistance.
Instruction:
Problem. Use input commands to ask the user for voltage and resistance, then calculate
the current using Ohm’s Law. Finally, output the current to the user.
Instruction:
𝑽
3. Calculate the current using the formula: 𝑰= 𝑹
4. Display the current using disp() or fprintf().
Problem. A resistor consumes power in a circuit. If the power exceeds 50 watts, the
program should display a warning. Otherwise, it should display the power consumption.
Instruction:
Problem. Provide DC circuit that can be classified based on the number of resistors
connected in the circuit. Based on the number of resistors, the circuit can be categorized
into the following:
Instruction:
Problem. Use a while loop to continuously prompt the user to input voltage and
resistance, calculate the power, and display the result. The program should only stop if
the user enters 0 for the voltage.
Instruction:
Problem. Use a for loop to calculate the total resistance of a set of resistors connected
in series. The user will input the number of resistors and then input the resistance
values one by one. The program will calculate the total resistance of the series circuit
and display it.
Instruction:
Deliverables:
1. Each group is required to submit their MATLAB files (.m) for all seven tasks listed
above. Submit all seven .m files, properly named, in a single compressed folder
labeled with your group name.
2. Groups are encouraged to collaborate and discuss solutions within their teams.
However, each group will need to present or demonstrate their solutions and
explain their approach to the class for their assigned problem:
• Group 1: Part 1
• Group 2: Part 2
• Group 3: Part 3
• Group 4: Part 4
• Group 5: Part 5
• Group 6: Part 6
• Group 7: Part 7
3. Along with the MATLAB files, each group should prepare a presentation in
PowerPoint format. The slides should adhere to the following guidelines:
• Title slide: Include the group number, the names of all members, and the
assigned task.
• Introduction: Briefly describe the problem or task you are addressing.
• Approach: Explain the logic, methods, and any algorithms used to solve the
task.
• Code snippets: Include relevant MATLAB code snippets and explain what
each part of the code does.
• Results: Show the results generated from your MATLAB code (e.g., output
values, plots, etc.).
Keep your slides concise and clear, limiting text where possible. Visual aids, such
as diagrams or charts, are encouraged.
4. Be prepared to explain your approach, the logic behind your solution, and make
sure your code works during the implementation when presenting in class.