-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPolar_NRZ.m
63 lines (62 loc) · 946 Bytes
/
Polar_NRZ.m
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
52
53
54
55
56
57
58
59
60
61
62
63
b = input('Enter bit message');
n =1;
l=length(b);
b(l+1)=1;
while n<length(b)
t=n-1:0.001:n;
y = t<=(n-0.5)+(t==n);
subplot(3,1,1);
d=plot(t,y);grid on;
title('CLOCK');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(b)-1 -1 1.5]);
n=n+1;
end
n=1;
subplot(3,1,2);
while n<length(b)
t=n-1:0.001:n;
if b(n) == 0
if b(n+1)==0
y=(t>n);
else
y=(t==n);
end
else
if b(n+1)==0
y=(t<n);
else
y=(t<=n);
end
end
d=plot(t,y);grid on;
title('BINARY DATA');
set(d,'LineWidth',2.5);
hold on;
n=n+1;
end
n=1;
subplot(3,1,3);
while n<length(b)
t=n-1:0.001:n;
if b(n) == 0
if b(n+1)==0
y=-(t<n)-(t==n);
else
y=-(t<n)+(t==n);
end
else
if b(n+1)==0
y=(t<n)-1*(t==n);
else
y=(t<n)+1*(t==n);
end
end
d=plot(t,y);grid on;
title('Line code POLAR NRZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(b)-1 -1.5 1.5]);
n=n+1;
end