summaryrefslogtreecommitdiff
path: root/1319/CH2/EX2.21
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:27:19 +0530
committerprashantsinalkar2017-10-10 12:27:19 +0530
commit7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch)
treedbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /1319/CH2/EX2.21
parentb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (diff)
downloadScilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.gz
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.bz2
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.zip
initial commit / add all books
Diffstat (limited to '1319/CH2/EX2.21')
-rw-r--r--1319/CH2/EX2.21/2_21.sce63
1 files changed, 63 insertions, 0 deletions
diff --git a/1319/CH2/EX2.21/2_21.sce b/1319/CH2/EX2.21/2_21.sce
new file mode 100644
index 000000000..dc29e39cc
--- /dev/null
+++ b/1319/CH2/EX2.21/2_21.sce
@@ -0,0 +1,63 @@
+// Determine current through branch AB using loop and nodal analysis
+
+clc;
+clear;
+
+Is=4; // Current Source
+//Resistances
+Rab=2;
+R1=4;// After point B towards the right
+R2=1;
+
+V=10; // Voltage source
+
+//Using Simple Logic
+i1=Is; // Current source connected in series with resistor
+i2=10/(R1+R2);
+
+printf('The Current through branch AB: \n')
+printf('i) Simple Logic = %g A\n',i1)
+
+//Using Loop Analysis
+
+//Conversion of Current source into voltage source, R tends to infinity
+
+R=poly(0,'R');
+
+Rmat=[R+2 0; 0 5];
+Vmat=[(4*R)-V;V];
+Imat=inv(Rmat)*Vmat;
+printf('\nii) Loop Analysis\n')
+disp(Imat(1,1),'The current through AB is')
+printf('\nWhere R tends to infinity\n')
+
+R=%inf;
+i1=(4-(V/R))/(1+(Rab/R));
+printf('\n = %g A\n',i1)
+
+// Using Nodal Analysis
+// Conversion of voltage source into current source, R then tends to zero
+
+R=poly(0,'R');
+
+// Nodal Eqaution
+//0.5V1-0.5V2+0V3 = 4
+//-0.5V1+(0.75+(1/R))V2-0.25V3 = 10/R
+//0V1-0.25V2+1.25V3=0
+
+Y=[0.5 -0.5 0;-0.5 (0.75+(1/R)) -0.25;0 -0.25 1.25]; // Admittance Matrix
+Im=[4; (10/R); 0] ; // Current Matrix
+Vm=inv(Y)*Im; // Voltage Matrix
+V1=Vm(1,1);
+V2=Vm(2,1);
+V3=Vm(3,1);
+
+DiffV=V1-V2;
+
+printf('\niii) Nodal Analysis:\n')
+disp(V2,'V2:',V1,'V1:')
+Vdiff=roots(DiffV(2)-R); // To change data type
+disp(DiffV,'V1-V2 :')
+In=Vdiff/Rab; // Current due to nodal analysis
+
+printf('\n The Current Through 2 ohm resistor = %g A\n',In )