PCM MODULATION
clc;
clear all;
t=0:0.005:10;
x=sin(t);
subplot(3,1,1);
plot(t,x,'green');
title('message signal');
xlabel('time(s)--->');
ylabel('Amplitude(V)-->');
grid on;
%%%%%%%%%%QUANTIZING SIGNAL%%%%%%%%%%%%
partition=-1:0.1:16;
codebook=-1:0.1:(16+0.1);
[index,quants] = quantiz(x,partition,codebook);
subplot(3,1,2);
plot(t,quants,'red');
title('Quantized signal');
xlabel('samples -->');
ylabel('Amplitude(V)-->');
grid on;
%%%%%%%%%%%%PCM SIGNAL%%%%%%%%%%%%%%%
y=uencode(quants,3);
subplot(3,1,3);
plot(t,y,'blue');
title('PCM signal')
xlabel('samples -->');
ylabel('Amplitude (V)-->');
grid on;
DELTA MODULATION
% DELTA MODULATiON
clc;
clear all;
close all;
a=2;
t=0:2*pi/50:2*pi;
x=a*sin(t);
l=length(x);
plot(x,'r');
delta=0.2;
hold on
xn=0;
for i=1:l;
if x(i)>xn(i)
d(i)=1;
xn(i+1)=xn(i)+delta;
else
d(i)=0;
xn(i+1)=xn(i)-delta;
end
end
stairs(xn)
hold on
for i=1:d
if d(i)>xn(i)
d(i)=0;
xn(i+1)=xn(i)-delta;
else
d(i)=1; xn(i+1)=xn(i)+delta;
end
end
plot(xn,'c');
legend('Analog signal','Delta modulation','Demodulation')
title('DELTA MODULATION / DEMODULATION ')