summaryrefslogtreecommitdiff
path: root/2297/CH2/EX2.2/Ex2_2.sce
blob: 3586610ac27417de00b1b9c1018ef594c7073b7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Example 2.2 :current
clc;
close;
clear;
// given :
vs1=72;//voltage in volts
vs2=40;//voltage in volts
R1=36;//resistance in ohm
R2=10;//resistance in ohm
ig=2;//current in amperes
Rx=8;//resistance in ohm
//(va-72)/36+(va-40)/10 -2 +va/8=0 node equation at 1
va=((R2*Rx*vs1)+(R1*Rx*vs2)+(R1*R2*Rx*ig))/((R2*Rx)+(R1*Rx)+(R1*R2));//voltage in volts
ix1=va/Rx;//current in amperes
//(R1+R2)*I1-R2*I2+vs2=vs1 loop equation 1
//R2*I2-R2*I1+Ix*Rx=vs2 loop equation 2
//Ix=I2+2
A=[R1+R2 -R2;-R2 R2+Rx];//making equations
B=[vs1-vs2;vs2-2*Rx];//making equations
X=A\B;//solving equations
ix2=X(2,1)+ig;//current in amperes
disp(ix1,"current through Rx is(by node voltage method), (A)=")
disp(ix2,"current through Rx is (by loop current method),(A) =")