Exp 10-11
Exp 10-11
Exp 10-11
clc;
clear all;
t=0:0.0005:20;
partition=-1:0.1:1;
codebook=-1:0.1:1.1;
x=sin(t);
[index,quants]=quantiz(x,partition,codebook);
subplot(3,1,1);
plot(t,x);
title('message signal');
xlabel('time');
ylabel('amplitude');
subplot(3,1,2);
plot(t,quants);
title('quantize signal');
xlabel('time');
ylabel('amplitude');
y= uencode(quants,3);
subplot(3,1,3);
plot(t,y);
title('pcm signal');
xlabel('time');
ylabel('amplitude');
Exp 11
clc;
clear all;
t=-10:01:10;
T=4;
fm=1/T;
x=cos(2*pi*fm*t);
subplot(2,2,1);
plot(t,x);
xlabel('time t');
ylabel('x(t)');
title('countinuous time signal');
grid;
n1=-4:1:4;
fs1=1.6*fm;
x1=cos(2*pi*fm/fs1*n1);
subplot(2,2,2);
stem(n1,x1);
xlabel('time t');
ylabel('x(n)');
title('discrete time signal with fs<2fm');
hold on;
subplot(2,2,2);
plot(n1,x1);
grid;
n2=-5:1:5;
fs2=2*fm;
x2=cos(2*pi*fm/fs2*n2);
subplot(2,2,3);
stem(n2,x2);
xlabel('time n');
ylabel('x(n)');
title('discrete time signal with fs=2fm');
hold on;
subplot(2,2,3);
plot(n2,x2);
grid;
n3=-20:1:20;
fs3=8*fm;
x3=cos(2*pi*fm/fs3*n3);
subplot(2,2,4);
stem(n3,x3);
xlabel('time n');
ylabel('x(n)');
title('discrete time signal with fs>2fm');
hold on;
subplot(2,2,4);
plot(n3,x3);
grid;