-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnipolar_RZ.m
68 lines (67 loc) · 1.02 KB
/
Unipolar_RZ.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
clc;
clear all;
close all;
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;
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 = (t==n);
end
else
if b(n+1)==1
y = t<=(n-0.5)+(t==n);
else
y = t<=(n-0.5);
end
end
d=plot(t,y);grid on;
title('Line code UNIPOLAR RZ reg no:68');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(b)-1 -1 1.5]);
xlabel('n');
ylabel('x[n]')
n=n+1;
end