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