summaryrefslogtreecommitdiff
path: root/845/CH5/EX5.2
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /845/CH5/EX5.2
downloadScilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip
initial commit / add all books
Diffstat (limited to '845/CH5/EX5.2')
-rwxr-xr-x845/CH5/EX5.2/Ex5_2.sce21
1 files changed, 21 insertions, 0 deletions
diff --git a/845/CH5/EX5.2/Ex5_2.sce b/845/CH5/EX5.2/Ex5_2.sce
new file mode 100755
index 000000000..76e6c91af
--- /dev/null
+++ b/845/CH5/EX5.2/Ex5_2.sce
@@ -0,0 +1,21 @@
+//Example 5.2
+clc
+clear
+
+x = [20 30 35 40 45 50];
+y = [10 11 11.8 12.4 13.5 14.4];
+
+X = x.^2;
+Y = y;
+
+n = length(Y);
+M1 = [sum(Y); sum(X.*Y)];
+M2 = [n sum(X); sum(X) sum(X.^2)];
+
+A = M2\M1;
+
+a = A(1);
+b = A(2);
+
+disp(round(a*10^4)/10^4, "a =")
+disp(round(b*10^4)/10^4, "b =")