Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Electric dipole
- % Where there are two point charges q and -q on the y-axis equally spaced from the
- % origin a point(P) lies somewhere on the x-axis
- % Notes are at the bottom of the code
- clc,clear
- % Constant
- k = 9*10^9; %[N*m^2/C^2] Coulomb's law constant
- % Variables
- d = input('Distance the point charges are away from each other in meters\n');
- q = input('Charge of q in Coulombs\n');
- % The distance here should be perpendicular to the distance between the
- % point charges and not "as the crow flies" from the charge q to point P
- x = input('Distance of point charges from point P in meters\n');
- E = k*q*d/x^3;;
- Ee = k*q*d/((d/2)^2+x^2);
- fprintf('The actual electric field is %e N/C, the approximate electric field is %e N/C', Ee, E)
- % Can be calculated by hand using the Pythagorean theorem
- % The approximate calculation is only if d<<x
- % Can be used as long as the distance from point P is measured from bisecting
- % the distance between the two point charges
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement