hiddenGem

Electric Potential of a Point Charge

Jun 4th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.61 KB | None | 0 0
  1. %% Electric Potential of a Point Charge
  2. % Calculates the electric potential of a point charge
  3. % As always notes are at the bottom of the code with any
  4. % clarifications.
  5.  
  6. % Constants
  7. k = 8.99*10^9                %[N*m^2/C^2] Coulombs constant
  8.  
  9. % Variables and inputs
  10. q = input('Point charge in Coulombs\n');
  11. r = input('Distance between the point charge and object in meters\n');
  12.  
  13. % Equations and outputs
  14. V = k*q/r;
  15. fprintf('The electric potential is %e V', V);
  16.  
  17. %{
  18. Under the assumption that there is one point charge creating an electric potential
  19.  
  20. Not to be confused with potential energy of a system
  21. %}
Add Comment
Please, Sign In to add comment