Advertisement
hiddenGem

Capacitance Sum

Jun 16th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.59 KB | None | 0 0
  1. %% Capacitance Sum
  2. % This script will calculate the sum of capacitors in series and in parallel
  3. % Notes and clarification are at the bottom of the code.
  4.  
  5. capacitances = input('Input capacitors values with brackets\n');
  6. a = input('Capacitance in series or in parallel?\n');
  7. switch a
  8.     case 1
  9.         cap1 = 1./capacitances;
  10.         cap2 = sum(cap1);
  11.         Cap = 1/cap2;
  12.     case 2
  13.         Cap = sum(capacitances);
  14. end
  15. fprintf('The sum of the capacitors is %i F \n',Cap)
  16. %{
  17. When a user inputs the capacitances, [] must be placed around the numbers for the
  18.     code to work properly
  19. %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement