%Spring 99 ECOMMS Class Demo
%S. Mandayam, Rowan University
%Mu-Law and A-Law Companding
clear;


x=[0:0.01:1];

%mu-law
mu=[1 5 100 255];
for i=1:4;
   y(i,:)=compand(x,mu(i),1,'mu/compressor');
end;

figure
plot(x,y);
xlabel('input w_1');
ylabel('output w_2');
title('\mu-Law Companding');
legend('\mu=1','\mu=5','\mu=100','\mu=255',4);

pause;

%A-law
A=[1 2 5 87.6 100];
for i=1:5;
   y(i,:)=compand(x,A(i),1,'A/compressor');
end;

figure
plot(x,y);
xlabel('input w_1');
ylabel('output w_2');
title('A-Law Companding');
legend('A=1','A=2','A=5','A=87.6','A=100',4);

