% ALTCODE - returns a strong alternating code set of specified length % one scan per row. For input not a power of 2, a truncated set of the % next power of 2 is returned. % The code sets are taken from [Nygrén, 1996, table 6.2 and 6.3] % and from inspection of the tau0 code % % See also WTT, TAU0CODE, AC_LP_WTT, AC_GATE_WTT, AC_LPH_WTT, % BCAC_LP_WTT, BCAC_GATE_WTT. % The 16-bit code marked tau0 below is what is used in the tau0 experiment, % randomised with the vector 45F1, or % [ 1 -1 1 1 1 -1 1 -1 -1 -1 -1 -1 1 1 1 -1 ] % $Id: altcode.m,v 1.3 2008-11-18 04:57:14 tom Exp $ % Copyright © 2003-2008 Tom Grydeland % This is free software, licensed under GNU GPL version 2 or later function codeset = altcode(bauds) w32 = walsh(32); if bauds <= 4, % 4-bit strong alternating code codeset = w32(1:8, [1 2 3 5]); elseif bauds <= 8, codeset = w32(1:16, [1 2 3 5 9 4 8 15]); codeset = w32(1:16, [1 2 3 5 9 13 6 12]); elseif bauds <= 16, codeset = w32(:, [1 2 3 5 9 17 16 32 18 13 26 30 21 7 14 27]); codeset = w32(:, [1 2 3 5 9 17 31 4 8 15 29 7 14 27 11 22]); % tau0 elseif bauds <= 32, w = walsh(64); codeset = w(:, [ 1 2 3 5 9 17 33 7 14 27 53 47 28 56 41 24 ... 48 25 50 37 16 32 63 59 52 34 6 12 23 45 31 62]); elseif bauds <= 64, w = walsh(128); codeset = ... w(:,[ 1 2 3 5 9 17 33 65 96 97 31 62 123 44 88 114 ... 61 122 46 92 106 13 26 51 101 24 48 95 100 25 50 99 ... 28 56 111 4 8 15 29 57 113 64 128 34 68 90 109 7 ... 14 27 53 105 16 32 63 125 40 80 66 93 103 19 38 75]); else error(sprintf('Codeset %d too large', baud)); end codeset = codeset(:, 1:bauds);