summaryrefslogtreecommitdiff
path: root/260/CH7/EX7.4/7_4.sce
diff options
context:
space:
mode:
Diffstat (limited to '260/CH7/EX7.4/7_4.sce')
-rw-r--r--260/CH7/EX7.4/7_4.sce55
1 files changed, 55 insertions, 0 deletions
diff --git a/260/CH7/EX7.4/7_4.sce b/260/CH7/EX7.4/7_4.sce
new file mode 100644
index 000000000..1e32db5ec
--- /dev/null
+++ b/260/CH7/EX7.4/7_4.sce
@@ -0,0 +1,55 @@
+//Eg-7.4
+//pg-336
+
+clear
+clc
+
+
+RH = [52 47 66 70 59 73 69];
+MC = [13 9 17 20 15 21 20];
+
+x = RH;
+y = MC;
+
+printf('\nAssuming that the equation is of the form : MC = c + m*RH\n')
+
+xavg = sum(x)/length(x);
+
+yavg = sum(y)/length(y);
+
+// Using S() for indicating 'sigma of'
+
+//using the equation a = S((xi - xavg) * (yi - yavg))/S(xi-xavg)^2;
+
+t = (x - xavg).*(y - yavg);
+
+u = (x - xavg).*(x - xavg);
+
+m = sum(t)/sum(u);
+
+printf(' The value of m = %f\n',m);
+
+c = yavg - m*xavg;
+
+printf(' The value of c = %f\n',c);
+
+[rx cx] = size(x);
+
+
+ymodel = c*ones(rx,cx) + m*x;
+yexperiment = y;
+
+printf('\n i MCiexperimental MCmodel\n')
+for(i = 1:cx)
+ printf(' %d %f %f\n',i-1,y(i),ymodel(i))
+end
+
+p = sum((ymodel - yavg*ones(rx,cx)).*(ymodel - yavg*(ones(rx,cx))));
+
+q = sum((y - yavg)^2);
+
+ r2 = p/q;
+
+ //using the equation [24]
+ printf('\nThe value of r^2 = %f\n',r2)
+ \ No newline at end of file