13 Resistors 7

When two resistors with resistances \(R1\) and \(R2\) are connected in parallel, the total resistance \(R\) is defined by the following equation:

\[\frac{1}{R} = \frac{1}{R1} + \frac{1}{R2}\]

In MATLAB, create a new function named parallelR that computes the total resistance of two resistors connected in parallel. The function should satisfy all of the following requirements:

  1. it should return a value named R equal to the total resistance of two parallel connected resistors
  2. it should be named parallelR
  3. it should have two input variables called R1 and R2 that represent the resistances of the two resistors
  4. it should contain a meaningful documentation comment
  5. it should compute and return the total resistance of the two parallel connected resistors

Save your function. Test your function in the MATLAB Command Window using some randomly chosen values of R1 and R2; for example, try calling your function as shown below and verify that your function returns the correct series resistance:

R = parallelR(100, 100)
R = parallelR(100, 400)
R = parallelR(400, 100)