Given the circuit diagram below create a GUI that will show
Given the circuit diagram below, create a GUI that will show the diagram in the GUI, take user inputs for V_s, R1, R2, R3, and R4, and calculate the equivalent resistance of the circuit and the voltage and current in each resistor.
Solution
function cktcal
Vs=input(\'Enter the Voltage source value\');
R1=input(\'Enter the R1 value\');
R2=input(\'Enter the R2 value\');
R3=input(\'Enter the R3 value\');
R4=input(\'Enter the R4 value\');
Req=((R2*R3)/(R2+R3))+R1+R4;
I=Vs/Req;
I1=I;
I4=I;
I2=I*(R3/(R3+R2));
I3=I-I2;
V1=I1*R1;
V2=I2*R2;
V3=I3*R3;
V4=I3*R4;
fprintf(\'The Equalant resitance is %0.2d\ \',Req);
fprintf(\'The Voltag across R1 is %0.2dV and current through R1 is %dA\ \',V1,I1);
fprintf(\'The Voltag across R2 is %0.2dV and current through R2 is %dA\ \',V2,I2);
fprintf(\'The Voltag across R3 is %0.2dV and current through R3 is %dA\ \',V3,I3);
fprintf(\'The Voltag across R4 is %0.2dV and current through R4 is %dA\',V4,I4);
