summaryrefslogtreecommitdiff
path: root/1415/CH1/EX1.4.3/ex3.sce
diff options
context:
space:
mode:
Diffstat (limited to '1415/CH1/EX1.4.3/ex3.sce')
-rw-r--r--1415/CH1/EX1.4.3/ex3.sce27
1 files changed, 27 insertions, 0 deletions
diff --git a/1415/CH1/EX1.4.3/ex3.sce b/1415/CH1/EX1.4.3/ex3.sce
new file mode 100644
index 000000000..9053c2ed6
--- /dev/null
+++ b/1415/CH1/EX1.4.3/ex3.sce
@@ -0,0 +1,27 @@
+//Example 3 Page 100
+clc
+clear
+
+x=[0 2 4 6 8 10 12 14]//assigning the values of x
+y=[9 9 10 11 11 12 13 13]//assigning the values of y
+disp(x,'x:')//displaying x values
+disp(y,'y:')//displaying y values
+xy=x.*y//calculating xy
+disp(xy,'xy:')//displaying xy values
+x2=x^2;//calculating x^2 values
+disp(x2,'x square:')//displaying x^2 values
+y2=y^2;//calculating y^2 values
+disp(y2,'y square:')//displaying y^2 values
+sumx=sum(x)//calculating sum of x
+disp(sumx,'sum(x)')//displaying x values
+sumy=sum(y)//calculating sum of y
+disp(sumy,'sum(y)')//displaying y values
+sumxy=sum(xy)//calculating sum of xy
+disp(sumxy,'sum(xy)')//displaying xy values
+sumx2=sum(x2)//calculating sum of x^2
+disp(sumx2,'sum(x2)')//displaying x^2 values
+sumy2=sum(y2)//calculating sum of y^2
+disp(sumy2,'sum(y2)')//displaying y^2 values
+n=8//given as n=8
+r=(((n*(sumxy))-(sumx*sumy))/((sqrt((n*sumx2)-((sumx)^2)))*(sqrt((n*sumy2)-((sumy)^2)))))//calculating r value
+disp(r,'the value of r is :')//displaying r value