Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Discharging a Capacitor Through a Resistor
- % Calculates the voltage across a capacitors after a certain amount of time
- % passes. Notes and clarifications are at the end of the code
- % Inputs and Variables
- C = input('What is the capacitance in Faradays?\n');
- V0 = input('What is the initial potential difference across the circuit in volts?\n');
- R = input('What is the resistance in ohms?\n');
- t = input('How many seconds later?\n');
- % Outputs and Equations
- V = V0*exp(-t/(R*C))
- fprintf('The new potential difference is %.4e V', V);
- %{
- The output is rounded to after the 4th decimal place. You can change this by
- adjusting or removing the .# in the fprintf line.
- %}
Add Comment
Please, Sign In to add comment