Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Pendulum in an Electric Field
- % Can calculate the angle of deflection in degrees and radians of a
- % pendulum in an electric field. Notes are at the bottom of the page
- % Constants
- g = 9.81; %[m/s^2] Acceleration due to gravity on earth
- % Variables
- q = input('The charge of mass object in Coulombs\n');
- E = input('The electric field in N/C\n');
- m = input('The mass of the charged object in kg\n');
- % Optional variable for relative permittivity
- Er = input('The relative permittivity if applicable (if not enter 1)\n');
- % Equations and output
- radians = round(atan((q*E/Er)/(m*g)), 3, 'significant');
- degrees = round(atand((q*E/Er)/(m*g)), 3, 'significant');
- a = input('Do you want the angle in radians, degrees, or both?\n');
- switch a
- case 1
- fprintf('The angle in radians is %i', radians)
- case 2
- fprintf('The angle in degrees is %i', degrees)
- case 3
- fprintf('The angle in radians and degrees is %i and %i', radians, degrees)
- end
- %{
- For the value of the electric field,
- V/m is equal to N/C so no conversions are necessary if the electric field
- is given in those units
- This program rounds to 3 significant figures.
- To change or remove this option see line 16 and 17
- This paste is different than my past "Function: Pendulum in Electric"
- Obviously that one is a function file and it will not ask for inputs.
- The other file does NOT round to three significant figures.
- Answers in the other paste will be given in matrix form.
- %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement