diff options
author | prashantsinalkar | 2017-10-10 12:38:01 +0530 |
---|---|---|
committer | prashantsinalkar | 2017-10-10 12:38:01 +0530 |
commit | f35ea80659b6a49d1bb2ce1d7d002583f3f40947 (patch) | |
tree | eb72842d800ac1233e9d890e020eac5fd41b0b1b /851 | |
parent | 7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (diff) | |
download | Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.tar.gz Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.tar.bz2 Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.zip |
updated the code
Diffstat (limited to '851')
-rwxr-xr-x | 851/CH5/EX05.13/Figure05_13.sce | 44 | ||||
-rwxr-xr-x | 851/CH5/EX5.13/Figure5_13.sce | 41 | ||||
-rwxr-xr-x | 851/CH6/EX6.2/Example6_2.sce | 110 | ||||
-rwxr-xr-x | 851/CH7/EX7.3/Table7_3.sce | 74 |
4 files changed, 145 insertions, 124 deletions
diff --git a/851/CH5/EX05.13/Figure05_13.sce b/851/CH5/EX05.13/Figure05_13.sce index 7aa878439..16954c055 100755 --- a/851/CH5/EX05.13/Figure05_13.sce +++ b/851/CH5/EX05.13/Figure05_13.sce @@ -1,16 +1,28 @@ -//clear//
-//Caption:A-law companding
-//Figure5.13(b)A-law companding, Nonlinear Quantization
-//Plotting A-law characteristics for different
-//Values of A
-clc;
-x = 0:0.01:1; //Normalized input
-A = [1,2,87.56];//different values of A
-for i = 1:length(A)
- [Cx(i,:),Xmax(i)] = Alaw(x,A(i));
-end
-plot2d(x/Xmax(1),Cx(1,:),2)
-plot2d(x/Xmax(2),Cx(2,:),4)
-plot2d(x/Xmax(3),Cx(3,:),6)
-xtitle('Compression Law: A-Law companding','Normalized Input |x|','Normalized Output |c(x)|');
-legend(['A =1'],['A=2'],['A=87.56'])
+//clear// +//Caption:A-law companding +//Figure5.13(b)A-law companding, Nonlinear Quantization +//Plotting A-law characteristics for different +//Values of A +clc; +function [ Cx , Xmax ] = Alaw (x , A ) +Xmax = max ( abs (x ) ) ; +for i = 1: length (x ) +if( x( i ) / Xmax < = 1/ A ) +Cx ( i) = A * abs ( x ( i) / Xmax ) ./(1+ log ( A ) ) ; +elseif ( x (i ) / Xmax > 1/ A ) +Cx ( i) = (1+ log ( A *abs ( x ( i ) / Xmax ) ) ) ./(1+ log( A ) ) ; +end +end +Cx = Cx / Xmax ; +Cx = Cx'; +endfunction +x = 0:0.01:1; //Normalized input +A = [1,2,87.56];//different values of A +for i = 1:length(A) + [Cx(i,:),Xmax(i)] = Alaw(x,A(i)); +end +plot2d(x/Xmax(1),Cx(1,:),2) +plot2d(x/Xmax(2),Cx(2,:),4) +plot2d(x/Xmax(3),Cx(3,:),6) +xtitle('Compression Law: A-Law companding','Normalized Input |x|','Normalized Output |c(x)|'); +legend(['A =1'],['A=2'],['A=87.56'])
\ No newline at end of file diff --git a/851/CH5/EX5.13/Figure5_13.sce b/851/CH5/EX5.13/Figure5_13.sce index 00b537f8a..61a4c6180 100755 --- a/851/CH5/EX5.13/Figure5_13.sce +++ b/851/CH5/EX5.13/Figure5_13.sce @@ -1,16 +1,25 @@ -//clear//
-//Caption:u-Law companding
-//Figure5.13(a)Mulaw companding Nonlinear Quantization
-//Plotting mulaw characteristics for different
-//Values of mu
-clc;
-x = 0:0.01:1; //Normalized input
-mu = [0,5,255];//different values of mu
-for i = 1:length(mu)
- [Cx(i,:),Xmax(i)] = mulaw(x,mu(i));
-end
-plot2d(x/Xmax(1),Cx(1,:),2)
-plot2d(x/Xmax(2),Cx(2,:),4)
-plot2d(x/Xmax(3),Cx(3,:),6)
-xtitle('Compression Law: u-Law companding','Normalized Input |x|','Normalized Output |c(x)|');
-legend(['u =0'],['u=5'],['u=255'])
+//clear// +//Caption:u-Law companding +//Figure5.13(a)Mulaw companding Nonlinear Quantization +//Plotting mulaw characteristics for different +//Values of mu +clc; + [Cx,Xmax] = mulaw(x,mu) + Xmax = max(abs(x)); + if(log(1+mu)~=0) + Cx = (log(1+mu*abs(x/Xmax))./log(1+mu)); + else + Cx = x/Xmax; + end +Cx = Cx/Xmax; //normalization of output vector +endfunction +x = 0:0.01:1; //Normalized input +mu = [0,5,255];//different values of mu +for i = 1:length(mu) + [Cx(i,:),Xmax(i)] = mulaw(x,mu(i)); +end +plot2d(x/Xmax(1),Cx(1,:),2) +plot2d(x/Xmax(2),Cx(2,:),4) +plot2d(x/Xmax(3),Cx(3,:),6) +xtitle('Compression Law: u-Law companding','Normalized Input |x|','Normalized Output |c(x)|'); +legend(['u =0'],['u=5'],['u=255'])
\ No newline at end of file diff --git a/851/CH6/EX6.2/Example6_2.sce b/851/CH6/EX6.2/Example6_2.sce index d93bcbe88..b8d13946d 100755 --- a/851/CH6/EX6.2/Example6_2.sce +++ b/851/CH6/EX6.2/Example6_2.sce @@ -1,55 +1,55 @@ -//clear//
-//Caption:Duobinary Encoding
-//Example6.2: Precoded Duobinary coder and decoder
-//Page 256
-clc;
-b = [0,0,1,0,1,1,0];//input binary sequence:precoder input
-a(1) = xor(1,b(1));
-if(a(1)==1)
- a_volts(1) = 1;
-end
-for k =2:length(b)
- a(k) = xor(a(k-1),b(k));
- if(a(k)==1)
- a_volts(k)=1;
- else
- a_volts(k)=-1;
- end
-end
-a = a';
-a_volts = a_volts';
-disp(a,'Precoder output in binary form:')
-disp(a_volts,'Precoder output in volts:')
-//Duobinary coder output in volts
-c(1) = 1+ a_volts(1);
-for k =2:length(a)
- c(k) = a_volts(k-1)+a_volts(k);
-end
-c = c';
-disp(c,'Duobinary coder output in volts:')
-//Duobinary decoder output by applying decision rule
-for k =1:length(c)
- if(abs(c(k))>1)
- b_r(k) = 0;
- else
- b_r(k) = 1;
- end
-end
-b_r = b_r';
-disp(b_r,'Recovered original sequence at detector oupupt:')
-//Result
-//Precoder output in binary form:
-//
-// 1. 1. 0. 0. 1. 0. 0.
-//
-// Precoder output in volts:
-//
-// 1. 1. - 1. - 1. 1. - 1. - 1.
-//
-// Duobinary coder output in volts:
-//
-// 2. 2. 0. - 2. 0. 0. - 2.
-//
-// Recovered original sequence at detector oupupt:
-//
-// 0. 0. 1. 0. 1. 1. 0.
+//clear// +//Caption:Duobinary Encoding +//Example6.2: Precoded Duobinary coder and decoder +//Page 256 +clc; +b = [0,0,1,0,1,1,0];//input binary sequence:precoder input +a(1) = bitxor(1,b(1)); +if(a(1)==1) + a_volts(1) = 1; +end +for k =2:length(b) + a(k) = bitxor(a(k-1),b(k)); + if(a(k)==1) + a_volts(k)=1; + else + a_volts(k)=-1; + end +end +a = a'; +a_volts = a_volts'; +disp(a,'Precoder output in binary form:') +disp(a_volts,'Precoder output in volts:') +//Duobinary coder output in volts +c(1) = 1+ a_volts(1); +for k =2:length(a) + c(k) = a_volts(k-1)+a_volts(k); +end +c = c'; +disp(c,'Duobinary coder output in volts:') +//Duobinary decoder output by applying decision rule +for k =1:length(c) + if(abs(c(k))>1) + b_r(k) = 0; + else + b_r(k) = 1; + end +end +b_r = b_r'; +disp(b_r,'Recovered original sequence at detector oupupt:') +//Result +//Precoder output in binary form: +// +// 1. 1. 0. 0. 1. 0. 0. +// +// Precoder output in volts: +// +// 1. 1. - 1. - 1. 1. - 1. - 1. +// +// Duobinary coder output in volts: +// +// 2. 2. 0. - 2. 0. 0. - 2. +// +// Recovered original sequence at detector oupupt: +// +// 0. 0. 1. 0. 1. 1. 0.
\ No newline at end of file diff --git a/851/CH7/EX7.3/Table7_3.sce b/851/CH7/EX7.3/Table7_3.sce index ec59df5cf..c6e943d10 100755 --- a/851/CH7/EX7.3/Table7_3.sce +++ b/851/CH7/EX7.3/Table7_3.sce @@ -1,37 +1,37 @@ -//clear//
-//Caption:Illustrating the generation of DPSK signal
-//Table7.3 Generation of Differential Phase shift keying signal
-clc;
-bk = [1,0,0,1,0,0,1,1];//input digital sequence
-for i = 1:length(bk)
- if(bk(i)==1)
- bk_not(i) =~1;
- else
- bk_not(i)= 1;
- end
-end
-dk_1(1) = 1&bk(1); //initial value of differential encoded sequence
-dk_1_not(1)=0&bk_not(1);
-dk(1) = xor(dk_1(1),dk_1_not(1))//first bit of dpsk encoder
-for i=2:length(bk)
- dk_1(i) = dk(i-1);
- dk_1_not(i) = ~dk(i-1);
- dk(i) = xor((dk_1(i)&bk(i)),(dk_1_not(i)&bk_not(i)));
-end
-for i =1:length(dk)
- if(dk(i)==1)
- dk_radians(i)=0;
- elseif(dk(i)==0)
- dk_radians(i)=%pi;
- end
-end
-disp('Table 7.3 Illustrating the Generation of DPSK Signal')
-disp('_____________________________________________________')
-disp(bk,'(bk)')
-bk_not = bk_not';
-disp(bk_not,'(bk_not)')
-dk = dk';
-disp(dk,'Differentially encoded sequence (dk)')
-dk_radians = dk_radians';
-disp(dk_radians,'Transmitted phase in radians')
-disp('_____________________________________________________')
+//clear// +//Caption:Illustrating the generation of DPSK signal +//Table7.3 Generation of Differential Phase shift keying signal +clc; +bk = [1,0,0,1,0,0,1,1];//input digital sequence +for i = 1:length(bk) + if(bk(i)==1) + bk_not(i) =~1; + else + bk_not(i)= 1; + end +end +dk_1(1) =bool2s( 1 & bk(1)); //initial value of differential encoded sequence +dk_1_not(1)=bool2s(0& bk_not(1)); +dk(1) = bitxor(dk_1(1),dk_1_not(1))//first bit of dpsk encoder +for i=2:length(bk) + dk_1(i) = dk(i-1); + dk_1_not(i) = ~dk(i-1); + dk(i) = bitxor(bool2s(dk_1(i)& bk(i)),bool2s(dk_1_not(i)& bk_not(i))); +end +for i =1:length(dk) + if(dk(i)==1) + dk_radians(i)=0; + elseif(dk(i)==0) + dk_radians(i)=%pi; + end +end +disp('Table 7.3 Illustrating the Generation of DPSK Signal') +disp('_____________________________________________________') +disp(bk,'(bk)') +bk_not = bk_not'; +disp(bk_not,'(bk_not)') +dk = dk'; +disp(dk,'Differentially encoded sequence (dk)') +dk_radians = dk_radians'; +disp(dk_radians,'Transmitted phase in radians') +disp('_____________________________________________________')
\ No newline at end of file |