📄 gps_ca_code.m
字号:
function prn=gps_ca_code(chips,gps_prn_num);
% This function generates a PRN code sequence for GPS
% sampled with 1 sample/chip
% prnvec = prncode( chips );
% chips = number of chips to generate
% gps_prn_num = GPS PRN number
G1=[ 1 1 1 1 1 1 1 1 1 1 ]; % Initial value for G1
prnvec=zeros(1,1023);
G2=[ 1 1 1 1 1 1 1 1 1 1 ]; % Initial value for G1
g2phase=ones(1,37);
for j=1:chips,
input=xor( G1(3), G1(10) ); % Use tap numbers 5 and 9 for feedback
prnvec1(j)=G1(10); % Use tap number 7 for output
G1x=[input,G1]; % Update shift register
G1=G1x(1:10);
input=0;
input1=xor( G2(2), G2(3) ); % Use tap numbers for feedback,
input2=xor( input1,G2(6) );
input3=xor( input2,G2(8) );
input4=xor( input3,G2(9) );
input=xor( input4,G2(10) );
g2phase(1)=xor( G2(2),G2(6) );
g2phase(2)=xor( G2(3),G2(7) );
g2phase(3)=xor( G2(4),G2(8) );
g2phase(4)=xor( G2(5),G2(9) );
g2phase(5)=xor( G2(1),G2(9) );
g2phase(6)=xor( G2(2),G2(10) );
g2phase(7)=xor( G2(1),G2(8) );
g2phase(8)=xor( G2(2),G2(9) );
g2phase(9)=xor( G2(3),G2(10) );
g2phase(10)=xor( G2(2),G2(3) );
g2phase(11)=xor( G2(3),G2(4) );
g2phase(12)=xor( G2(5),G2(6) );
g2phase(13)=xor( G2(6),G2(7) );
g2phase(14)=xor( G2(7),G2(8) );
g2phase(15)=xor( G2(8),G2(9) );
g2phase(16)=xor( G2(9),G2(10) );
g2phase(17)=xor( G2(1),G2(4) );
g2phase(18)=xor( G2(2),G2(5) );
g2phase(19)=xor( G2(3),G2(6) );
g2phase(20)=xor( G2(4),G2(7) );
g2phase(21)=xor( G2(5),G2(8) );
g2phase(22)=xor( G2(6),G2(9) );
g2phase(23)=xor( G2(1),G2(3) );
g2phase(24)=xor( G2(4),G2(6) );
g2phase(25)=xor( G2(5),G2(7) );
g2phase(26)=xor( G2(6),G2(8) );
g2phase(27)=xor( G2(7),G2(9) );
g2phase(28)=xor( G2(8),G2(10) );
g2phase(29)=xor( G2(1),G2(6) );
g2phase(30)=xor( G2(2),G2(7) );
g2phase(31)=xor( G2(3),G2(8) );
g2phase(32)=xor( G2(4),G2(9) );
g2phase(33)=xor( G2(5),G2(10) );
g2phase(34)=xor( G2(4),G2(10) );
g2phase(35)=xor( G2(1),G2(7) );
g2phase(36)=xor( G2(2),G2(8) );
g2phase(37)=xor( G2(4),G2(10) );
%PRN number 12,19,21,32,33,34,35,36,37 are not in use now
prnvec2(j)=g2phase(gps_prn_num); % Use tap number 7 for output
G2x=[input,G2]; % Update shift register
G2=G2x(1:10);
prnvec(j)=xor( prnvec1(j),prnvec2(j));
prn(j)=prnvec(j);
prn(j)=(prnvec(j)-0.5)*2;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -