-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDCpcm.asv
51 lines (46 loc) · 854 Bytes
/
DCpcm.asv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
clc;
close all;
clear all;
n=input('enter n value for n-bit PCM system:');
n1=input('enter number of samples in a period');
L=2^n;
x=0:2*pi/n1:4*pi;
s=8*sin(x);
subplot(3,1,1);
plot(s);
title('analaog signal');
ylabel('amplitude--->');
xlabel('time--->');
subplot(3,1,2);
stem(s);
grid on;
title('sampled signal');
ylabel('amplitude--->');
xlabel('time--->');
vmax=8;
vmin=-vmax;
del=(vmax-vmin)/L;
part=vmin:del:vmax;
code=vmin-(del/2):del:vmax+(del/2);
[ind,q]=quantiz(s,part,code);
l1=length(ind);
l2=length(q);
for i=1:l1
if(ind(i)==0)
ind(i)=ind(i)-1;
end
i=i+1;
end
for i=1:l2
if(q(i)==vmin-(del/2))
q(i)=vmin+(del/2);
end
end
subplot(3,1,3);
stem(q);
grid on;
title('quantized signal');
ylabel('amplitude--->');
xlabel('time--->');
figure
code=de2bi