Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

[a] (15 points) Write a MATLAB function findEquiv such that \' S \' , \' R\' ) r

ID: 2265623 • Letter: #

Question

[a] (15 points) Write a MATLAB function findEquiv such that ' S ' , ' R' ) returns the equivalent resistance of any number of findEquiv (Values, 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',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 and 'L' stand for capacitors and inductors, respectively) findEquiv(Values, 'SI and findEquiv(Values, 'P,'I" perform the same . returned by the function will be complex).

Explanation / Answer

function f=findEquiv(values,c,co)
if (co=='r')||(co=='l')||(co=='i')
if c=='s'
f=sum(values);
elseif c=='p'
f=values.^-1;
f=f.^-1;
end
elseif co=='c'
if c=='s'
f=values.^-1;
f=f.^-1;
elseif c=='p'
f=sum(values);
end
end

>> findEquiv([1 6 6 2 3 4],'s','r')

ans =

22

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote