-
Notifications
You must be signed in to change notification settings - Fork 0
/
AMINRZ.m
58 lines (57 loc) · 1.01 KB
/
AMINRZ.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
function AMINRZ(h)
%Line code AMI NRZ.
%Author: Diego Orlando Barragán Guerrero
%For more information, visit: www.matpic.com
%diegokillemall@yahoo.com
%Example:
%h=[1 0 0 1 1 0 1 0 1 0];
%AMINRZ(h)
clf;
n=1;
l=length(h);
h(l+1)=1;
ami=-1;
while n<=length(h)-1;
t=n-1:0.001:n;
if h(n) == 0
if h(n+1)==0
y=(t>n);
else
if ami==1
y=-(t==n);
else
y=(t==n);
end
end
d=plot(t,y);grid on;
title('Line code AMI NRZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5 1.5]);
disp('zero');
else
ami=ami*-1;
if h(n+1)==0
if ami==1
y=(t<n);
else
y=-(t<n);
end
else
if ami==1
y=(t<n)-(t==n);
else
y=-(t<n)+(t==n);
end
end
%y=(t>n-1)+(t==n-1);
d=plot(t,y);grid on;
title('Line code AMI NRZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5 1.5]);
disp('one');
end
n=n+1;
%pause;
end