diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /659/CH9/EX9.5 | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '659/CH9/EX9.5')
-rwxr-xr-x | 659/CH9/EX9.5/exm9_5.sci | 27 | ||||
-rwxr-xr-x | 659/CH9/EX9.5/exm9_5_output.PNG | bin | 0 -> 8467 bytes |
2 files changed, 27 insertions, 0 deletions
diff --git a/659/CH9/EX9.5/exm9_5.sci b/659/CH9/EX9.5/exm9_5.sci new file mode 100755 index 000000000..e97f8e561 --- /dev/null +++ b/659/CH9/EX9.5/exm9_5.sci @@ -0,0 +1,27 @@ +// Example 9.5
+//Write a program to calculate standard deviation of an array values.
+//Array elements are read from terminal.Use functions to calulate-
+//standard deviation and mean
+funcprot(0);
+//passing array named 'value' to function std_dev at 'a'
+function[std]=std_dev(a,n)
+ sum1=0;
+ x=mean1(a,n); //calling mean1() function
+ for i=1:n
+ sum1=sum1+(x-a(i))^2;
+ std=sqrt(sum1/double(n)); //computes standard deviation
+ end
+endfunction
+function[x]=mean1(a,n)
+ sum1=0;
+ for i=1:n
+ sum1=sum1+a(i);
+ x=sum1/double(n); //x contain mean value
+ end
+endfunction
+SIZE=int8(5); //size of array
+printf("Enter %d float values",SIZE);
+for i=1:SIZE
+ value(i)=input(" "); //entering values in the array
+end
+printf("Std.deviation is %f",std_dev(value,SIZE)); //calling std_dev() function
\ No newline at end of file diff --git a/659/CH9/EX9.5/exm9_5_output.PNG b/659/CH9/EX9.5/exm9_5_output.PNG Binary files differnew file mode 100755 index 000000000..9c7dc68cc --- /dev/null +++ b/659/CH9/EX9.5/exm9_5_output.PNG |