summaryrefslogtreecommitdiff
path: root/70/CH2/EX2.5.1/2_5_1.sci
diff options
context:
space:
mode:
Diffstat (limited to '70/CH2/EX2.5.1/2_5_1.sci')
-rwxr-xr-x70/CH2/EX2.5.1/2_5_1.sci21
1 files changed, 21 insertions, 0 deletions
diff --git a/70/CH2/EX2.5.1/2_5_1.sci b/70/CH2/EX2.5.1/2_5_1.sci
new file mode 100755
index 000000000..8452e5853
--- /dev/null
+++ b/70/CH2/EX2.5.1/2_5_1.sci
@@ -0,0 +1,21 @@
+//page 121
+clear;
+close;
+clc;
+disp('Applying current law A''y=f at nodes 1,2,3:')
+A=[-1 1 0;0 -1 1; -1 0 1;0 0 -1;-1 0 0];
+disp(A','A''=');
+C=diag(rand(5,1)); //Taking some values for the resistances.
+b=zeros(5,1);
+b(3,1)=rand(1);//Taking some value of the battery.
+f=zeros(3,1);
+f(2,1)=rand(1);//Taking some value of the current source.
+B=[b;f];
+disp('The other equation is inv(C)y+Ax=b.The block form of the two equations is:')
+C=[inv(C) A;A' zeros(3,3)];
+disp(C);
+X=['y1';'y2';'y3';'y4';'y5';'x1';'x2';'x3'];
+disp(X,'X=')
+X=C\B;
+disp(X,'X=');
+//end \ No newline at end of file