diff options
Diffstat (limited to '1319/CH2/EX2.23/2_23.sce')
-rw-r--r-- | 1319/CH2/EX2.23/2_23.sce | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/1319/CH2/EX2.23/2_23.sce b/1319/CH2/EX2.23/2_23.sce new file mode 100644 index 000000000..302835de6 --- /dev/null +++ b/1319/CH2/EX2.23/2_23.sce @@ -0,0 +1,34 @@ +//To find voltage v and current through 3 ohm resistor using nodal analysis
+
+clc;
+clear;
+
+V=poly(0,'V');
+
+Va=8-V;
+Vb=-6;
+
+//Resistors in order from the 8V side
+R1=1;
+R2=2;
+R3=3;
+R4=4;
+
+// Nodal Analysis
+
+X=((8-Va)/R1)+((Vb-Va)/R3)-((Va-(4*V))/R2); // Characteristic equation to find V
+
+V=roots(X);
+
+Va=8-V;
+
+I=(Vb-Va)/3;
+
+printf('i) The Voltage V (across 1 ohm resistor) is %g V\n',V)
+
+if(imag(sqrt(I))) // Condition to check for negative sign
+ printf('ii) The Current through 3 ohm resistor is %g A flowing from A to B\n',abs(I))
+else
+printf('ii) The Current through 3 ohm resistor is %g A flowing from B to A\n',abs(I))
+end
+
|