The question uses the two formulas for finding the series and the parallel resis
ID: 3796253 • Letter: T
Question
The question uses the two formulas for finding the series and the parallel resistance using matlab
Write a function that computes the equivalent resistance of a simple resistive circuit consisting of only series-connected or parallel-connected resistors. You function should accept two inputs as follows:
A vector of any length greater than or equal to 2 that contains the resistance values of two or more resistors.
A single character variable that is equal to "S" to indicate a series connection or "P" to indicate a parallel connection.
The function should output a single scalar that is the equivalent resistance of the circuit that is computed using the appropriate formula as described above.
Explanation / Answer
function [EquResistance] = student_solution(Resistance,TYPE)
SUM = 0;
if(TYPE == 'S' || TYPE == 's')
for i= 1 : length(Resistance)
SUM = SUM + Resistance(i);
end
EquResistance= SUM;
elseif (TYPE == 'P' || TYPE == 'p')
for i= 1 : length(Resistance)
SUM = SUM + 1/Resistance(i);
end
EquResistance = 1/SUM;
end
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.