Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Electric Circuit of 5 Resistors
- % Determines the equivalent resistance of the circuit
- % Notes and Clarifications are at the end of the code
- % Inputs and Variables
- resis = input('Input resistances in brackets\n');
- % Outputs and Equations
- Rtot = resis(1) + resis(4) + (resis(3)*(resis(2)+resis(5)))/(resis(3)+(resis(2)+resis(5)));
- fprintf('The total resistance is %.3e \n', Rtot);
- if range(resis) == 0
- a = input('Would you like the calculate the current through R2 or R5? Y/N \n ', 's');
- if a == 'Y'
- V = input('What is the voltage of the circuit?\n');
- I = (V/Rtot)/resis(1);
- fprintf('The current running through R2/R5 is %.3e A \n', I)
- end
- end
- %{
- The 'if' statement input requires a Y as a response to proceed with
- calculating the optional step.
- Under the assumption that the resistors are in an 'x' formation while the
- numbering of the resistors is in a 'z' formation with R1 at the top left
- and R5 is at the bottom right.
- If all the resistors have equal resistance, the amount of current that goes
- into R2 or R5 can be calculated. It can be calculated by finding the net
- current and dividing it by the resistance of an individual resistor.
- The code will run this optional path if requirements are met.
- To solve this manually
- R2 and R5 are in series so they are added together to equal R25
- R3 and R25 are is parallel so the inverse of the inverses added
- together equal R3,25
- R1, R4, and R3,25 are in series so they are added together
- %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement