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

xn is defined by: H x1 x2 Write a user-defined function that calculates the harm

ID: 2082281 • Letter: X

Question

xn is defined by: H x1 x2 Write a user-defined function that calculates the harmonic mean of a set of numbers. For vector of numbers (any length) and the output argument H is their harmonic mean. In electrical engineering the equivalent resistance of resistors connected in parallel is equal to the harmonic mean of the values of the resistors divided by the number of the resistors. Use the user-defined function Harmean to calculate the equivalent resistance of the resistors shown in the figure. Answer Req 61.7544

Explanation / Answer

Matlab Script:

function H = Harmean(x)
sum = 0;
for i=1:length(x)
sum = sum+inv(x(i));%taking the sum of inverse of each element
end
H = 1/sum;
end

command window log:

>> Req = Harmean([250 320 550 160 1000])

Req =

61.7544

>>

Navigate



Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.