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.1.3/ex3.sce | |
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.1.3/ex3.sce')
-rw-r--r-- | 1415/CH1/EX1.1.3/ex3.sce | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/1415/CH1/EX1.1.3/ex3.sce b/1415/CH1/EX1.1.3/ex3.sce new file mode 100644 index 000000000..e8362ff3b --- /dev/null +++ b/1415/CH1/EX1.1.3/ex3.sce @@ -0,0 +1,43 @@ +//Example 3 Page 48
+clc
+clear
+//defining the function
+function y=f(x)
+if(x >= -4 & x < -1) then//check value of x
+y=-1;
+elseif(x >= -1 & x <= 1) then//check value of x
+y=x;
+elseif(x > 1 & x <= 2) then//check value of x
+y=x^2-1;
+end
+endfunction
+
+disp('a)')
+x=-2;//assigning value to x
+y=f(x)//function calling
+disp(y)
+x=-1;//assigning value to x
+y=f(x)//function calling
+disp(y)
+x=0;//assigning value to x
+y=f(x)//function calling
+disp(y)
+x=1;//assigning value to x
+y=f(x)//function calling
+disp(y)
+x=2;//assigning value to x
+y=f(x)//function calling
+disp(y)
+
+disp('b)')
+x=[-4 -3 ]//assigning values to x
+y=f(x)//function calling
+disp(y)
+plot(4,4,x,y,'green')//plotting on graph
+x=[-1 0 1]//assigning values to x
+y=f(x)//function calling
+plot(4,4,x,y,'red')//plotting on graph
+x=[1.1 1.3 1.5 2]//assigning values to x
+y=f(x)//function calling
+plot(4,4,x,y,'blue')//plotting on graph
+xtitle('','x','y');
|