diff options
author | prashantsinalkar | 2017-10-10 12:27:19 +0530 |
---|---|---|
committer | prashantsinalkar | 2017-10-10 12:27:19 +0530 |
commit | 7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch) | |
tree | dbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /1415/CH1/EX1.4.2 | |
parent | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (diff) | |
download | Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.gz Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.bz2 Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.zip |
initial commit / add all books
Diffstat (limited to '1415/CH1/EX1.4.2')
-rw-r--r-- | 1415/CH1/EX1.4.2/ex2.jpg | bin | 0 -> 25999 bytes | |||
-rw-r--r-- | 1415/CH1/EX1.4.2/ex2.sci | 28 |
2 files changed, 28 insertions, 0 deletions
diff --git a/1415/CH1/EX1.4.2/ex2.jpg b/1415/CH1/EX1.4.2/ex2.jpg Binary files differnew file mode 100644 index 000000000..5542e2e1c --- /dev/null +++ b/1415/CH1/EX1.4.2/ex2.jpg diff --git a/1415/CH1/EX1.4.2/ex2.sci b/1415/CH1/EX1.4.2/ex2.sci new file mode 100644 index 000000000..2de9e56e5 --- /dev/null +++ b/1415/CH1/EX1.4.2/ex2.sci @@ -0,0 +1,28 @@ +//Example 2 Page 98
+clc
+clear
+
+x=[0 2 4 6 8 10 12 14]//assigning x values as given
+disp(x,'Years:')//displaying the x values
+y=[9 9 10 11 11 12 13 13]//assigning the y values
+disp(y,'Per capital GDP:')//displaying y values
+xy=x.*y//calculating xy values
+disp(xy,'xy:')//displaying xy values
+x2=x^2//calculating x^2 values
+disp(x2,'square of x')//displaying x^2 values
+n=8;//given n=8 data points
+disp(sum(x),'sumof x:')//finding the sum of x
+disp(sum(y),'sumof y:')//finding the sum of y
+disp(sum(xy),'sumof xy:')//finding the sum of xy
+disp(sum(x2),'sumof xsquare:')//finding the sum of x2
+m=((n*(sum(xy)))-((sum(x))*(sum(y))))/((n*(sum(x2)))-(sum(x)^2));//calculating m value
+disp(m,'m value is:')//displaying m values
+b=(sum(y)-(m*sum(x)))/n//calculating b value
+disp(b,'b value is:')//displaying b value
+
+function y=f(x)//function for regression line
+ y=m*x+b
+endfunction
+y=f(x)//calling function
+plot(x,y)//plotting graph between x and y
+xtitle('data point and regression line','x','y')//naming the axex
|