Advertisement
hiddenGem

Resistor Connected to a real Battery

Jun 20th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.74 KB | None | 0 0
  1. %% Resistor Connected to a Real Battery
  2. % Calculates the internal resistance r, the electric current, the power
  3. %   dissipated by the external resistor and battery, and the efficiency of
  4. %   the circuit
  5.  
  6. % Inputs and Variables
  7. R = input('Resistance of the resistor in Ohms\n');
  8. epsilon = input('What is the electromotive force in Volts?\n');
  9. deltaVt = input('The terminal voltage drop in Volts\n');
  10.  
  11. % Outputs and Equations
  12. I = deltaVt/R;
  13. r = (epsilon-deltaVt)/I;
  14. PR = R*I^2;
  15. Pr = r*I^2;
  16. Eff = PR/(Pr+PR);
  17. fprintf(['The internal resistance, electric current, power dissipated by \n '...
  18.        'the external and internal resistor, and the efficiency are \n', ...
  19.        '%.4e Ohm,  %.3i A, %.3i W, %.3i W, %.3i \n'], r, I, Pr, PR, Eff)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement