-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUNRZ.m
45 lines (45 loc) · 868 Bytes
/
UNRZ.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
function UNRZ(h)
%Line code UNIPOLAR 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];
%UNRZ(h)
clf;
n=1;
l=length(h);
h(l+1)=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
y=(t==n);
end
d=plot(t,y);grid on;
title('Line code UNIPOLAR NRZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5 1.5]);
disp('zero');
else
if h(n+1)==0
%y=(t>n-1)-2*(t==n);
y=(t<n)-0*(t==n);
else
%y=(t>n-1)+(t==n-1);
y=(t<n)+1*(t==n);
end
%y=(t>n-1)+(t==n-1);
d=plot(t,y);grid on;
title('Line code UNIPOLAR 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