Advertisement
hiddenGem

Balanced Wheatstone

Jun 20th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.86 KB | None | 0 0
  1. %% Balanced Wheatstone
  2. % Calculates the resistance in R1
  3. % Notes and clarifications are at the bottom of the code
  4.  
  5. % Inputs and Variables
  6. Rsub = input('Input the values of R2, R3, and R4 in brackets\n');
  7. for i = 1:3
  8.     R(i+1) = Rsub(i)
  9. end
  10.  
  11. % Outputs and Equations
  12. R(1) = R(2)*R(3)/R(4);
  13. fprintf('The resistance of R1 is %.3f', R(1))
  14.  
  15. %{
  16. Later versions will allow users to choose which resistor the user would
  17.     like to solve for.
  18. In this scenario, the circuit runs between R1 and R3 and R2 and R4. R1 and
  19.     R3 are on the left side and R1 and R2 are on the top side.
  20. When the user inputs values R2-4, they will take the first 3 spots of the
  21.     array 'Rsub'. The for loop will put the resistance values in their corresponding
  22.     place in the array 'R'
  23. The user must input the values of the known resistances in brackets [] for
  24.     the code to work.
  25. %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement