(30 points) Wirite a Maab function tindBquiy such that findEquiv (Values, \'s\',
ID: 2248444 • Letter: #
Question
(30 points) Wirite a Maab function tindBquiy such that findEquiv (Values, 's', 'R') returns the equivalent resistance of any number of resistors in series (the second argument 's' stands for "series"), the values of which are saved in the one dimensional array Values findEquiv (Values, 'p, 'R) returns the equivalent resistance of any number of resistors in parallel '' stands for "parallel") * findEquiv (Values, 'S','C) and findEquiv(Values, 'P', 'c') perform the same for capacitors findEquiv (Values, 's', 'L') and findEquiv(Values, 'P, 'L') perform the same for inductors (i.e. the third arguments c' and 'L' stand for capacitors and inductors, respectively)Explanation / Answer
function equiv = findEquiv(Values, config1, element1)
inv_sum = sum(1./Values);
st_sum = sum(Values);
if strcmp(config1,'S')
if strcmp(element1,'R')
equiv = st_sum;
elseif strcmp(element1,'L')
equiv = st_sum;
elseif strcmp(element1,'C')
equiv = inv_sum;
end
elseif strcmp(config1,'P')
if strcmp(element1,'R')
equiv = inv_sum;
elseif strcmp(element1,'L')
equiv = inv_sum;
elseif strcmp(element1,'C')
equiv = st_sum;
end
end
command window log:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.