Advertisement
hiddenGem

Conducting Sphere

May 28th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.01 KB | None | 0 0
  1. %% Conducting Sphere
  2. % Calculates the electric flux from distance r for a CONDUCTING sphere
  3. % Notes and clarifications are at the end of the paste like always
  4.  
  5. % Constants
  6. k = 8.99*10^9;               %[N*m^2/C^2] Coulombs constant
  7.  
  8. % Variables and inputs
  9. R = input('What is the radius of the sphere in meters?\n');
  10. r = input('What is distance, in meters, away from center of the sphere?\n');
  11. Q = input('What is the net charge on the conducting sphere in Coulombs?\n');
  12.  
  13. % Equation and outputs
  14. if r < R
  15.     Ein = 0;
  16.     fprintf('The distance is inside the sphere.\n The electric flux is %i N/C \n',Ein)
  17. elseif r == R
  18.     Erad = 0;
  19.     fprintf('The distance is the radius.\n The electric flux is %i N/C \n', Erad);
  20. else
  21.     Eout = k*(Q/r^2);
  22.     fprintf('The distance is outside the radius.The electric flux is %i\n N/C \n', Eout)
  23. end
  24.  
  25. %{
  26. Under the assumption that the net charge sits on the surface of the sphere
  27.  
  28. See paste "Insulating Sphere" for a net charge evenly distributed
  29. throughout the material
  30. %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement