Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The circuit diagram below shows resistors connected in series. The equivalent resistance for n resistors connected in series is given by Requiv = R 1

The circuit diagram below shows resistors connected in series. The equivalent resistance for n resistors connected in series is given by Requiv = R1+ R2+ R3+...+ Rn. The next circuit diagram below shows resistors connected in parallel. The equivalent resistance is given by Requiv =1/(1/R1+1/R2+...+1/Rn). Code has already been started that defines a function named ResistorFun that accepts two input variables defined as follows: 1. The variable ResistorValues is a vector of any length greater than or equal to 2 that contains the resistance values of two or more resistors. 2. The variable Series_or_Parallel is a single character variable that is equal to the text "S" or the number 1 to indicate a series connection, or the text "P" or the number 2 to indicate a parallel connection. Add code to the function to use the appropriate formula (as described above) to compute the equivalent resistance of a simple resistive circuit consisting of only series-connected or parallel-connected resistors. Your code should compute a single scalar value that is the equivalent resistance of the circuit and assign that value to the function output variable EquivResistance. If the second input is not one of the specified options for series or parallel, then the function output should change to the message "Second input invalid." Use an if-elseif-else structure in your solution. Also, the sum function will be useful. Note: The variables ResistorValues and Series_or_Parallel are defined as inputs to the function. Do not overwrite these values in your code. Be sure to assign a value to the output variable EquivResistance.
The circuit diagram below shows resistors connected in series. The equivalent resistance for n resistors connected in series is given by Requiv = R1+ R2+ R3+...+ Rn.
The next circuit diagram below shows resistors connected in parallel. The equivalent resistance is given by Requiv =1/(1/R1+1/R2+...+1/Rn).
Code has already been started that defines a function named ResistorFun that accepts two input variables defined as follows:
1. The variable ResistorValues is a vector of any length greater than or equal to 2 that contains the resistance values of two or more resistors.
2. The variable Series_or_Parallel is a single character variable that is equal to the text "S" or the number 1 to indicate a series connection, or the text "P" or the number 2 to indicate a parallel connection.
Add code to the function to use the appropriate formula (as described above) to compute the equivalent resistance of a simple resistive circuit consisting of only series-connected or parallel-connected resistors. Your code should compute a single scalar value that is the equivalent resistance of the circuit and assign that value to the function output variable EquivResistance. If the second input is not one of the specified options for series or parallel, then the function output should change to the message "Second input invalid."
Use an if-elseif-else structure in your solution. Also, the sum function will be useful.
Note: The variables ResistorValues and Series_or_Parallel are defined as inputs to the function. Do not overwrite these values in your code. Be sure to assign a value to the output variable EquivResistance.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions