登录后复制
% the basic codes from the generating poly from the book spread spectrum applications on commercial systems
function[code1, code2] = BasicSeq(m)
N = 2^m - 1;
sreg = [0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1]; % register for code 1
sreg2 = [0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1]; % register for code 2
code1 = zeros(1, N);
code2 = zeros(1, N);
switch m
case 3
for i=1:N
code1(i) = sreg(m);
first = mod(sreg(2) + sreg(3), 2);
sreg = circshift(sreg, [0, 1]);
sreg(1)=first;
code2(i) = sreg2(m);
first2 = mod(sreg2(1) + sreg2(3), 2);
sreg2 = circshift(sreg2, [0, 1]);
sreg2(1)=first2;
end
case 5
for i=1:N
code1(i) = sreg(m);
first = mod(sreg(3) + sreg(5), 2);
sreg = circshift(sreg, [0, 1]);
sreg(1)=first;
code2(i) = sreg2(m);
first2 = mod(sreg2(1) + sreg2(2) + sreg2(3) + sreg2(5), 2);
sreg2 = circshift(sreg2, [0, 1]);
sreg2(1)=first2;
end
case 7
for i=1:N
code1(i) = sreg(m);
first = mod(sreg(4) + sreg(7), 2);
sreg = circshift(sreg, [0, 1]);
sreg(1)=first;
code2(i) = sreg2(m);
first2 = mod(sreg2(4) + sreg2(5) + sreg2(6) + sreg2(7), 2);
sreg2 = circshift(sreg2, [0, 1]);
sreg2(1)=first2;
end
case 8
for i=1:N
code1(i) = sreg(m);
first = mod(sreg(1) + sreg(2) + sreg(3) + sreg(6) + sreg(7) + sreg(8), 2);
sreg = circshift(sreg, [0, 1]);
sreg(1)=first;
code2(i) = sreg2(m);
first2 = mod(sreg2(1) + sreg2(2) + sreg2(7) + sreg2(8), 2);
sreg2 = circshift(sreg2, [0, 1]);
sreg2(1)=first2;
end
case 9
for i=1:N
code1(i) = sreg(m);
first = mod(sreg(5) + sreg(9), 2);
sreg = circshift(sreg, [0, 1]);
sreg(1)=first;
code2(i) = sreg2(m);
first2 = mod(sreg2(3) + sreg2(5) + sreg2(6) + sreg2(9), 2);
sreg2 = circshift(sreg2, [0, 1]);
sreg2(1)=first2;
end
case 10
for i=1:N
code1(i) = sreg(m);
first = mod(sreg(7) + sreg(10), 2);
sreg = circshift(sreg, [0, 1]);
sreg(1)=first;
code2(i) = sreg2(m);
first2 = mod(sreg2(2) + sreg2(7) + sreg2(8) + sreg2(10), 2);
sreg2 = circshift(sreg2, [0, 1]);
sreg2(1)=first2;
end
case 11
for i=1:N
code1(i) = sreg(m);
first = mod(sreg(9) + sreg(11), 2);
sreg = circshift(sreg, [0, 1]);
sreg(1)=first;
code2(i) = sreg2(m);
first2 = mod(sreg2(3) + sreg2(8) + sreg2(9) + sreg2(11), 2);
sreg2 = circshift(sreg2, [0, 1]);
sreg2(1)=first2;
end
end
版本:2014a
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删