Advertisement
hiddenGem

Q = CV

Jun 16th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.01 KB | None | 0 0
  1. %% Q = CV
  2. % Uses the above equation to solve for other variables
  3. % Notes and clarifications are at the bottom of the code
  4.  
  5. a = input('Are you solving for charge, capacitance, or voltage?\n');
  6. switch a
  7.     case 1      % Charge
  8.         C = input('What is the capacitance in faradays?\n');
  9.         V = input('What is the voltage in volts?\n');
  10.         Q = C*V;
  11.         fprintf('The charge is %e C \n',Q)
  12.     case 2      % Capacitance
  13.         Q = input('What is the charge in coulombs?\n');
  14.         V = input('What is the voltage in volts? \n');
  15.         C = Q/v;
  16.         fprintf('The capacitance is %e F', C)
  17.     case 3      % Voltage
  18.         C = input('What is the capacitance in faradays');
  19.         Q = input('What is the charge in coulombs?');
  20.         V = Q/C;
  21.         fprintf('THe voltage is %i V',V);
  22. end
  23.  
  24.  
  25. %{
  26. It should be noted that Q = charge in coulombs, C = Capatiance in faraday,
  27.     V = Voltage or Potential Difference in volts.
  28. Most problems will probably call voltage as potential difference
  29. %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement