summaryrefslogtreecommitdiff
path: root/3446/CH24
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:27:19 +0530
committerprashantsinalkar2017-10-10 12:27:19 +0530
commit7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch)
treedbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /3446/CH24
parentb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (diff)
downloadScilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.gz
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.bz2
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.zip
initial commit / add all books
Diffstat (limited to '3446/CH24')
-rw-r--r--3446/CH24/EX24.1/Ex_D1.sce45
-rw-r--r--3446/CH24/EX24.2/Ex_D2.sce46
2 files changed, 91 insertions, 0 deletions
diff --git a/3446/CH24/EX24.1/Ex_D1.sce b/3446/CH24/EX24.1/Ex_D1.sce
new file mode 100644
index 000000000..ba4ca267e
--- /dev/null
+++ b/3446/CH24/EX24.1/Ex_D1.sce
@@ -0,0 +1,45 @@
+// Exa D.1
+// Using the shift register shown in Figure D.3, generate an m-sequence and demonstrate its properties.
+
+clc;
+clear all;
+
+//solution
+//Referring Fig D.3
+x=[0 0 1]; //Initial stage
+output=x(3);
+disp(" First m-sequence using 3-stage shift register.");
+disp(" x1 x2 x3 output");
+printf(' Initial %d %d %d %d \n ',x(1),x(2),x(3),output);
+for i= 1:7
+ printf('Shift %d',i);
+ x(3)=x(2);
+ if(x(3)==1) //TO get values in range of [-1 1] for plot
+ dummy(i)=-1
+else
+ dummy(i)=1;
+ end
+ x(2)=x(1);
+ if(output== 1& x(3)==1) //As new x(1)=prev stage x(3) ored prev stage x(2)
+ x(1)=0;
+ else
+ if(output== 0& x(3)==0)
+ x(1)=0;
+ else
+ x(1)=1;
+ end
+ end
+
+ printf(' %d %d %d ',x(1),x(2),x(3));
+ output=x(3);
+ printf(' %d',output);
+ printf('\n ');
+end
+bar(dummy,0.2,'green');
+xlabel("Time","FontSize",5);
+title("7-chip first m-sequence for one T period","FontSize",5);
+disp("The properties of m-sequence in Figure(0)are -");
+disp("Number of -1s = 4 , Number of 1s = 3 ");
+disp("Run length 1 = 2 , Run length 2 = 1");
+disp("Run length = 1");
+
diff --git a/3446/CH24/EX24.2/Ex_D2.sce b/3446/CH24/EX24.2/Ex_D2.sce
new file mode 100644
index 000000000..0d5ab4995
--- /dev/null
+++ b/3446/CH24/EX24.2/Ex_D2.sce
@@ -0,0 +1,46 @@
+// Exa D.2
+// what is the location of the modulo-2 adder for the second m-sequence? Generate the second m-sequence.
+
+clc;
+clear all;
+
+//solution
+disp("The location of modulo-2 adder for the second m-sequence is shown in Figure D.5(in the book)i.e Modulo-2 adder should be between first(x1) and second(x2) shift register.");
+x=[0 0 1]; //Initial stage
+output=x(3);
+disp("Second m-sequence usinf 3-stage register");
+disp(" x1 x2 x3 output");
+printf(' Initial %d %d %d %d \n ',x(1),x(2),x(3),output);
+for i= 1:7
+ printf('Shift %d',i);
+ x(3)=x(2);
+ if(x(3)==1) //TO get values in range of [-1 1] for plot
+ dummy(i)=-1
+else
+ dummy(i)=1;
+ end
+ x(2)=x(1);
+ if(output== 1& x(2)==1) //As new x(1)=prev stage x(3) ored prev stage x(2)
+ x(1)=0;
+ else
+ if(output== 0& x(2)==0)
+ x(1)=0;
+ else
+ x(1)=1;
+ end
+ end
+
+ printf(' %d %d %d ',x(1),x(2),x(3));
+ output=x(3);
+ printf(' %d',output);
+ printf('\n ');
+end
+figure(1);
+bar(dummy,0.2,'green');
+xlabel("Time","FontSize",5);
+title("7-chip second m-sequence for one T period","FontSize",5);
+disp("The properties of m-sequence in Figure(1)are -");
+disp("Number of -1s = 4 , Number of 1s = 3 ");
+disp("Run length 1 = 2 , Run length 2 = 1");
+disp("Run length = 1");
+