summaryrefslogtreecommitdiff
path: root/851/CH5
diff options
context:
space:
mode:
Diffstat (limited to '851/CH5')
-rwxr-xr-x851/CH5/EX05.13/Figure05_13.sce44
-rwxr-xr-x851/CH5/EX5.13/Figure5_13.sce41
2 files changed, 53 insertions, 32 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