📄 cacode.m
字号:
function CA= cacode(n, chiprate, fs, n_samples)
% The code is represented at levels: -1 for bit = 0
% % 1 for bit = 1
% chiprate = 1.023e6;
% fs=64e6;
% n_samples = 16368data(1:64000,1);
% n = 5;
%%%%reference GPSoft TOOLBOX
aa=n;
if aa>=40
prn=aa-80;
else
prn=aa;
end
% phase assignments
delay_select = [5;6;7;8;17;18;139;140;141;251;252;254;255;256;257;258;469;470;471;472;473;474;509;512;513;514;515;516;859;860;861;862;863;950;947;948;950;0;0
145;175;52;21;237;235;886;657;634;762;355;1012;176;603;130;359;595;68;386]; %prn 120 delay=delay_shift(40) .........
% initial state - all ones
R1 = -1*ones(1,10);
R2 = R1;
for k=1:1023,
G1(k)=R1(10);
temp1 =R1(3)*R1(10);
R1(2:10)=R1(1:9);
R1(1)=temp1;
G2(k)=R2(10);
temp2 =R2(2)*R2(3)*R2(6)*R2(8)*R2(9)*R2(10);
R2(2:10)=R2(1:9);
R2(1)=temp2;
end,
shift=delay_select(prn);
shiftG2(shift+1:1023)=G2(1:1023-shift);
shiftG2(1:shift)=G2(1023-shift+1:1023);
ca1=G1.*shiftG2;
%Resample - doesn't work for (i*chiprate/fs)>1023
%but replica chiprate is constant in this implementation
i= 1:n_samples;
CA(i) = ca1(mod(ceil(i*chiprate/fs),1023)+1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -