added
git-svn-id: http://moon:8086/svn/matlab/trunk@100 801c6759-fa7c-4059-a304-17956f83a07c
This commit is contained in:
Executable
+64
@@ -0,0 +1,64 @@
|
||||
function y = manchester(x, type)
|
||||
N = length(x);
|
||||
|
||||
mtype = 'ieee802.3';
|
||||
if (nargin > 1)
|
||||
mtype = type
|
||||
end
|
||||
|
||||
t = -1;
|
||||
v = -1;
|
||||
|
||||
if (strcmp(mtype, 'I') || strcmp(mtype, 'ieee802.3'))
|
||||
v = 0;
|
||||
t = 1;
|
||||
end
|
||||
|
||||
if (strcmp(mtype, 'II') || strcmp(mtype, 'Thomas'))
|
||||
v = 0;
|
||||
t = 2;
|
||||
end
|
||||
|
||||
if (strcmp(mtype, 'BP-M'))
|
||||
v = 1;
|
||||
t = 1;
|
||||
end
|
||||
|
||||
if (strcmp(mtype, 'BP-S'))
|
||||
v = 0;
|
||||
t = 1;
|
||||
end
|
||||
|
||||
if (t == 1)
|
||||
s = 1;
|
||||
y = [];
|
||||
for n=1:N,
|
||||
if x(n) == v
|
||||
s = not(s);
|
||||
y = [y s];
|
||||
y = [y s];
|
||||
else
|
||||
s = not(s);
|
||||
y = [y s];
|
||||
s = not(s);
|
||||
y = [y s];
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (t == 2)
|
||||
s = 1;
|
||||
y = [];
|
||||
for n=1:N,
|
||||
if x(n) == v
|
||||
y = [y not(s)];
|
||||
y = [y s];
|
||||
else
|
||||
y = [y s];
|
||||
y = [y not(s)];
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user