Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Insulating sphere
- % Calculates the electric flux from distance r for an INSULATING sphere
- % Notes and clarifications for the code are at the bottom
- % Constants
- k = 8.99*10^9; %[N*m^2/C^2] Coulombs constant
- % Variables and inputs
- R = input('What is the radius of the sphere in meters?\n');
- r = input('What is distance, in meters, away from center of the sphere?\n');
- Q = input('What is the net charge on the conducting sphere in Coulombs?\n');
- % Equation and outputs
- if r < R
- Ein = (k*Q*r)/R^3;
- fprintf('The distance is inside the sphere.\n The electric flux is %i N/C \n',Ein)
- elseif r == R || r > R
- Eout = k*(Q/r^2);
- fprintf('The distance is outside the radius. The electric flux is %i N/C \n', Eout)
- end
- %{
- Under the assumption there is an electric charge evenly distributed
- throughout the insulating material.
- See paste "Conducting Sphere" for a net charge that sits on the surface of
- the sphere
- %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement