Created
April 17, 2012 04:15
-
-
Save jc245410/2403408 to your computer and use it in GitHub Desktop.
Total Resistance Calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % Calculate Series and Parallel Resistances of two resistors | |
| % | |
| % ___________________ | |
| % enter ohms ---> | calculate total | -----> display total ohmage | |
| % |___________________| | |
| % | |
| % Series Resistors | |
| % Totalresistance = R1 + r2 | |
| % | |
| % Parallel Resistors | |
| % totalresistance = 1/r1 + 1/r2+ | |
| % | |
| clear | |
| clc | |
| % | |
| % Outline 1: Get how many resistors the user would like and in Parallel or | |
| % Series | |
| % | |
| resistancetype=input('Choose between 1. Resistance in Series, or 2. Resistance in Parallel: '); | |
| % | |
| % Outline 2:Get the amount of ohms each resistor is | |
| % | |
| resistance1=input('Enter the first resistors resistance: '); | |
| resistance2=input('Enter the second resistors resistance: '); | |
| % | |
| % Outline 3: | |
| % | |
| % | |
| % Outline 4: calculate the total resistance | |
| % | |
| if resistancetype==1; | |
| totalresistance = resistance1+resistance2; | |
| disp('The total resistance in series is equal to: ') | |
| disp(totalresistance) | |
| disp('ohms.') | |
| else resistancetype==2; | |
| totalresistance = 1/resistance1 + 1/resistance2; | |
| disp('The total resistance in parallel is equal to: ') | |
| disp(totalresistance) | |
| disp('ohms.') | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment