ENGR 1181 | MATLAB 15: Functions MAT_15D_Functions_Assignment

Follow the format that you’ve been doing for previous problems.

·  Do the entire problem in one script file.

·  Your script file should include comment statements to help organize your script file.

·  Make sure the Command Window displays your name, the assignment name, and your group number.

·  Submit based on your instructor’s guidelines.

Background

While electrical engineers use circuits often, other types of engineers use them to perform experiments and design products, as well. Thus, learning about basic principles of circuits is important for all engineers.

Define

You are an electrical engineer working with some circuit boards. You have many versions of the circuit shown below and you need to write a program to compute the equivalent resistance, Req, of the circuit to determine which board you need to use.

You will write a program that includes two user written functions. The first user written function will compute the equivalent resistance from N resistors in parallel. The resistors in parallel are the ones that are vertically stacked on top of each other. The equation for equivalent resistance, RPeq, of N resistors in parallel is given below:

1RPeq=1RP1+1RP2 +1RP3+…+1RPN

After computing the equivalent resistance of the parallel resistors, RPeq, the circuit can be redrawn, substituting RPeq for the set of parallel resistors.

As a result you now have a set of only resistors in series (horizontally attached to one another). The second user written function will compute the equivalent resistance from M resistors in series. Be sure to include the parallel equivalent resistance, RPeq, in this computation. The equation for equivalent resistance, Req, of M resistors in series is given below:

Req=R1+R2+R3+…+RM

A help sheet that includes a sample calculation is included at the end of this assignment.

The user will input the number of resistors in parallel and the number of additional resistors in series. For example Circuit A has 4 resistors in parallel and 3 additional resistors in series. Then, the user will input the resistance in Ohms (Ω) of each resistor, in order. Set up the program to run repeatedly until the user quits the program.

Instructions

Represent

·  Consider making a flowchart or algorithm to represent your solution process.

Plan

·  Create a script file

·  Include comment statements in your program to plan out the solution.

Implement

·  Part 1:

-  Write a function file for calculating the equivalent resistance for N resistors in parallel.

§  The function should be sent a vector that contains all the resistances. You may send other information as needed.

§  The function should return the equivalent resistance.

-  Print the function file to pdf and submit to the Carmen Dropbox. Continue on to Part 2.

·  Part 2:

-  Write a function file for the series resistors.

-  In the script file, perform the following tasks:

§  Prompt the user for all inputs

§  Compute the equivalent resistance of the resistors using the two functions described above.

§  Display this value to the screen

§  Prompt the user to see if he/she wants to quit.

§  Repeat the program if necessary. You may need to clear the vectors. To clear individual variables type clear and then the variable name.

-  Use the program to determine which circuits (A-D) on the following page give an equivalent resistance of 1300 Ω. Add an fprintf() statement to the end of your program which prints to the command window the answer.

-  Your program must be run to show the results for all 4 circuits given.

Evaluate

·  Perform a hand calculation to verify your answer.

Document

·  Print (paper or pdf depending on instructor preference) the final version of your script file.

·  Print (paper or pdf depending on instructor preference) the command window output.

·  Print (paper or pdf depending on instructor preference) the calculation for the evaluate step.

·  If paper: Staple the script file, function files, output, and verification together and turn it in.

·  If pdf: Combine pdf files together and submit to Carmen Dropbox.

A) 

B) 

C) 

D) 

Equivalent Resistance Sample Calculation

If given the circuit shown below, the following steps outline how to compute the equivalent resistance:

1)  There are 4 resistors in parallel and 3 additional resistors in series.

2)  Compute the equivalent resistance of the resistors in parallel (5Ω, 10 Ω, 20 Ω, 20 Ω).

1RPeq=1RP1+1RP2 +1RP3+…+1RPN

1RPeq=15Ω+110Ω+120Ω+120Ω=0.4

RPeq=2.5Ω

3)  Redraw the circuit

4)  Compute the equivalent resistance of the resistors in series (including the parallel equivalent resistance just computed).

Req=R1+R2+R3+…+RM

Req=25Ω+2.5Ω+45Ω+65Ω

Req=137.5Ω

5)  The equivalent resistance of the circuit is 137.5Ω.