-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbipolar_nrz.m
74 lines (71 loc) · 1.1 KB
/
bipolar_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
64
65
66
67
68
69
70
71
72
73
74
b = input('Enter bit message');
l=length(b);
b(l+1)=1;
n = 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;
count=1;
parity=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);
else
y=parity*(t==n);
end
else
if b(n+1)==0
y=parity*(t<n);
else
y=parity*(t<n)-parity*(t==n);
end
end
if b(n)==1
count = count+1;
end
if mod(count,2)
parity = 1;
else
parity = -1;
end
d=plot(t,y);grid on;
title('Line code BIPOLAR NRZ reg no:68');
set(d,'LineWidth',2.5);
hold on;
n=n+1;
end