f=2;
fs=1000;
t=0:1/fs:1;
a=2;
sig=asin(2pift);
sig1=sig+a;
q=round(sig1);
q1=q-a;
enco=de2bi(q,'left-msb');
deco=bi2de(enco,'left-msb');
deco1=deco-a;
hl=fir1(100,0.2/fs,'low');
signo=conv(deco1,hl);
t_n=(0:length(signo)-1)*1/fs;
subplot(3,1,1);
plot(t,sig);
hold on
plot(t,q1);
hold on;
xlabel('Time');
ylabel('Amplitude');
title('signal,quantised,pcm');
plot(t,enco);
subplot(3,1,2);
plot(t,deco1);
xlabel('Time');
ylabel('Amplitude');
title('decoded');
subplot(3,1,3);
plot(t_n,signo);
xlabel('Time');
ylabel('Amplitude');
title('Demodulatd');