Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Q = CV
- % Uses the above equation to solve for other variables
- % Notes and clarifications are at the bottom of the code
- a = input('Are you solving for charge, capacitance, or voltage?\n');
- switch a
- case 1 % Charge
- C = input('What is the capacitance in faradays?\n');
- V = input('What is the voltage in volts?\n');
- Q = C*V;
- fprintf('The charge is %e C \n',Q)
- case 2 % Capacitance
- Q = input('What is the charge in coulombs?\n');
- V = input('What is the voltage in volts? \n');
- C = Q/v;
- fprintf('The capacitance is %e F', C)
- case 3 % Voltage
- C = input('What is the capacitance in faradays');
- Q = input('What is the charge in coulombs?');
- V = Q/C;
- fprintf('THe voltage is %i V',V);
- end
- %{
- It should be noted that Q = charge in coulombs, C = Capatiance in faraday,
- V = Voltage or Potential Difference in volts.
- Most problems will probably call voltage as potential difference
- %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement