summaryrefslogtreecommitdiff
path: root/291/CH9/EX9.8b/eg9_8b.sce
diff options
context:
space:
mode:
Diffstat (limited to '291/CH9/EX9.8b/eg9_8b.sce')
-rwxr-xr-x291/CH9/EX9.8b/eg9_8b.sce26
1 files changed, 26 insertions, 0 deletions
diff --git a/291/CH9/EX9.8b/eg9_8b.sce b/291/CH9/EX9.8b/eg9_8b.sce
new file mode 100755
index 000000000..e18564e37
--- /dev/null
+++ b/291/CH9/EX9.8b/eg9_8b.sce
@@ -0,0 +1,26 @@
+x = [0.5 1 1.5 2 3 4 5 6 8 10];
+y= [15 15.1 16.5 19.9 27.7 29.7 26.7 35.9 42 49.4];
+for i=1:10
+ w(i) = 1/x(i);
+end
+//disp(w)
+n = 10;
+p = zeros(2,2);
+q = zeros(2, 1);
+p(1, 1) = sum(w);
+p(1,2) = n;
+p(2,1) = n;
+p(2,2) = sum(x);
+for i=1:10
+ new(i) = w(i)*y(i)
+end
+
+q(1,1)= -1*sum(new);
+q(2,1) = -1*sum(y);
+//disp(p);
+//disp(q);
+sol = linsolve(p,q);
+A = sol(1,1 );
+B = sol(2,1);
+disp(A, "A is");
+disp(B, "B is"); \ No newline at end of file