Write a MATLAB function findEquiv such that findEquiv (Values, \'S\', \'R\') ret
ID: 3573081 • Letter: W
Question
Write a MATLAB function findEquiv 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 ('P' 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) findEquiv (Values, 'S', 'I') and findEquiv (Values, 'P', 'I') perform the same for complex values of impedances (in this case, the numbers saved in Values, as well as that returned by the function will be complex). Include this code with your report.Explanation / Answer
function R = findEquiv(Values, string, type)
if string=='S' && type=='R'
R = sum(Values);
elseif string=='P' && type=='R'
R = sum(1./Values);
elseif string=='S' && type=='C'
R = sum(1./Values);
elseif string=='P' && type=='C'
R = sum(Values);
elseif string =='S' && type=='L'
R = sum(Values);
elseif string=='P' && type=='L'
R = 1/sum(1./Values);
end
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.