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 /1241/CH3/EX3.6/exa3_6.sce | |
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 '1241/CH3/EX3.6/exa3_6.sce')
-rwxr-xr-x | 1241/CH3/EX3.6/exa3_6.sce | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/1241/CH3/EX3.6/exa3_6.sce b/1241/CH3/EX3.6/exa3_6.sce new file mode 100755 index 000000000..71d0da64b --- /dev/null +++ b/1241/CH3/EX3.6/exa3_6.sce @@ -0,0 +1,30 @@ +//Example 3-6//
+//binary to gray code//
+clc
+//clears the console//
+clear
+//clears all existing variables//
+a=1001011
+for i=1: 7
+ x(i)=modulo(a,10)
+ a=a/10
+ a=floor(a)
+end
+y(7)=x(7)
+k=6
+while(k>0)
+ if bitand(x(k+1),x(k))==1 then
+ y(k)=bitcmp(1,1)
+ else
+ y(k)=bitor(x(k+1),x(k))
+ end
+ k=k-1
+end
+//display//
+z=0
+for i=1: 7
+ z=z+y(i)*(10^(i-1))
+end
+disp('equivalent gray code')
+disp(z)
+//equivalent gray code is displayed//
|