You are on page 1of 3

Task # 1

f=8000;
T=1/f;
n=0:T:0.02;
x_o=50*sin(200*pi*n);
for i=1:length(x_o)
[ii,pq(i)]=biquant(4,-5,5,x_o(i));

Lab # 3

end
for i=1:length(x_o)
pqp(i)=biqtdec(4,-5,5,pq(i));
end
error=pq-pqp;
figure
stem(n,x_o,'b')
hold on
stem(n,pq,'g')
hold on
stem(n,error,'r')
title('Quantization Process With Error')
xlabel('Time')
ylabel('Amplitude')
legend('Original Signal','Quantized Signal','Error in Quantization Process')
hold off
[snr] = calcsnr(x_o,pq);

Home Work
nob=4;
xmax=5;
xmin=-5;
fs=8000;
T=1/fs;
n=0:T:0.02;
xa=50*sin(200*pi*n);
figure(1)

subplot(2,2,1)
plot(n,xa)
hold on
stem(n,xa)
hold off
title('original signal')
xlabel('time')
ylabel('Amplitude')
l=length(xa);
for i=1:l
[ii,pq(i)]=biquant(nob,xmin,xmax,xa(i));
end
subplot(2,2,2)
stem(n,pq)
title('discrete Quantized Signal')
xlabel('time')
ylabel('amlitude')
subplot(2,2,3)
plot(n,pq)
title('Continuous Quantized Signal')
xlabel('time')
ylabel('amlitude')
for i=1:l
pqp(i)=biqtdec(nob,xmin,xmax,pq(i))
end
error=pqp-pq
subplot(2,2,4)
stem(n,error)
title('Error')
xlabel('time')
ylabel('amlitude')
qsig=biquant(nob,xmin,xmax,xa)
snr=calcsnr(xa,pq)
fs1=200;
T1=1/fs1;
n1=0:T1:0.02;
xa1=50*sin(200*pi*n1)
figure(5)
subplot(2,2,1)
plot(n1,xa1)
hold on
stem(n1,xa1)
hold off
title('nyquist')
xlabel('time')
ylabel('amlitude')
fs2=150;
T2=1/fs2;
n2=0:T2:0.02;
xa2=50*sin(200*pi*n2)
subplot(2,2,2)
plot(n2,xa2)
hold on
stem(n2,xa2)
hold off
title('Low nyquist')
xlabel('time')

ylabel('amlitude')
fs3=250;
T3=1/fs3;
n3=0:T3:0.02;
xa3=50*sin(200*pi*n3)
subplot(2,2,3)
plot(n3,xa3)
hold on
stem(n3,xa3)
hold off
title('high nyquist')
xlabel('time')
ylabel('amlitude')

You might also like