Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Conducting Sphere
- % Calculates the electric flux from distance r for a CONDUCTING sphere
- % Notes and clarifications are at the end of the paste like always
- % 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 = 0;
- fprintf('The distance is inside the sphere.\n The electric flux is %i N/C \n',Ein)
- elseif r == R
- Erad = 0;
- fprintf('The distance is the radius.\n The electric flux is %i N/C \n', Erad);
- else
- Eout = k*(Q/r^2);
- fprintf('The distance is outside the radius.The electric flux is %i\n N/C \n', Eout)
- end
- %{
- Under the assumption that the net charge sits on the surface of the sphere
- See paste "Insulating Sphere" for a net charge evenly distributed
- throughout the material
- %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement