American International University-Bangladesh Department of Computer Science Lab Report Cover Sheet Course Name Student Name Student Id Lab Report No
American International University-Bangladesh Department of Computer Science Lab Report Cover Sheet Course Name Student Name Student Id Lab Report No
Student Id 18-39135-3
Section E
Performance Task for Lab Report: (your ID = AB-CDEFG-H)
x(t) = (H+5)*cos(2π((D+E+5)*10)t) + (H+7)*sin(2π((E+F+10)*10)t)
Q: Apply uniform quantization on signal ‘x(t)’ using both of the manual quantization
methods learnt in this manual. Use (2^H + 2) levels for first method and use (12 – 2^H )
levels for the second one. Attach codes and necessary figures in your report.
Ans:
My Id: 18-39135-3
A = 1;
B = 8;
C = 3;
D = 9;
E = 1;
F = 3;
G = 5;
H = 3;
MATLAB CODE
clc
close all
A1 = 8;
B1 = 10;
Am = A1 + B1;
bit = 3.4;
f1 = 150;
f2 = 140;
f = f1 + f2;
fs = 30000;
t = 0:1/fs:1/f;
y = 8*cos(2*pi*150*t) + 10*sin(2*pi*140*t);
Nsamples=length(y);
quantised_out=zeros(1,Nsamples);
del= (max(y)-min(y))/(2^bit);
Llow=-Am+del/2;
Lhigh=Am-del/2;
for i=Llow:del:Lhigh
for j=1:Nsamples
if(((i-del/2)<=y(j))&&(y(j)<=(i+del/2)))
quantised_out(j)=i;
end
end
end
plot(t,y,'r-.', 'linewidth',1.5);
hold on;
plot(t,quantised_out,'k-.', 'linewidth',1.5);
xlabel('time')
ylabel('amplitude')
title('example of manual quantization method 1')
legend('Original signal','quantized signal')
METHOD:2
x(t) = 8*cos(2π(15*10)t) + 10*sin(2π(14*10)t)
Levels = (12 - 2H) = (12 – 23) = 4
clc
close all
fs = 5000;
f1 = 150;
f2 = 140;
f = f1 + f2;
t = 0:1/fs:1/f;
A = 8;
B = 10;
x = 8*cos(2*pi*150*t) + 10*sin(2*pi*140*t);
L = 4;
delta=(max(x)-min(x))/(L-1);
xq = min(x)+(round((x-min(x))/delta)).*delta;
plot(t,x,'r-.', 'linewidth',1.5);
hold on;
plot(t,xq,'k-.', 'linewidth',1.5);
xlabel('time')
ylabel('amplitude')
title('example of manual quantization method 1')
legend('Original signal','quantized signal')