git-svn-id: http://moon:8086/svn/matlab/trunk@100 801c6759-fa7c-4059-a304-17956f83a07c
65 lines
704 B
Matlab
Executable File
65 lines
704 B
Matlab
Executable File
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
|
|
|