Advertisement
hiddenGem

Electric Dipole on x-y plane

May 27th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.89 KB | None | 0 0
  1. %% Electric dipole
  2. % Where there are two point charges q and -q on the y-axis  equally spaced from the
  3. % origin a point(P) lies somewhere on the x-axis
  4. % Notes are at the bottom of the code
  5.  
  6.  
  7. clc,clear
  8. % Constant
  9. k = 9*10^9;                      %[N*m^2/C^2] Coulomb's law constant
  10.  
  11. % Variables
  12. d = input('Distance the point charges are away from each other in meters\n');
  13. q = input('Charge of q in Coulombs\n');
  14. % The distance here should be perpendicular to the distance between the
  15. % point charges and not "as the crow flies" from the charge q to point P
  16. x = input('Distance of point charges from point P in meters\n');
  17. E = k*q*d/x^3;;
  18. Ee = k*q*d/((d/2)^2+x^2);
  19. fprintf('The actual electric field is %e N/C, the approximate electric field is %e N/C', Ee, E)
  20.  
  21. % Can be calculated by hand using the Pythagorean theorem
  22. % The approximate calculation is only if d<<x
  23. % Can be used as long as the distance from point P is measured from bisecting
  24. % the distance between the two point charges
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement