✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
全球定位系统(GPS)使用的信号频谱包括L1、L2和L5三个频段。L1频段的中心频率为1575.42 MHz,L2频段的中心频率为1227.60 MHz,L5频段的中心频率为1176.45 MHz。
其中,L1频段是GPS主要信号频段,它是一种带有码伪造的载波信号,可用于计算位置、速度和时间等信息;L2频段是GPS的辅助信号频段,可用于计算大气延迟误差等信息;L5频段是GPS的高精度信号频段,其波长更短,受多径误差以及干扰影响较小,可提供更加准确的定位数据。
此外,GPS还包括P码和C/A码信号,其中P码信号使用在L1和L2频段,提供高精度的定位数据;C/A码信号是低精度信号,主要用于民用卫星导航。
⛄ 部分代码
function CAcode = generateCAcode(PRN)
% generateCAcode.m generates one of the 32 GPS satellite C/A codes.
%
% CAcode = generateCAcode(PRN)
%
% Inputs:
% PRN - PRN number of the sequence.
%
% Outputs:
% CAcode - a vector containing the desired C/A code sequence
% (chips).
%--------------------------------------------------------------------------
% SoftGNSS v3.0
%
% Copyright (C) Darius Plausinaitis
% Written by Darius Plausinaitis
% Based on Dennis M. Akos, Peter Rinder and Nicolaj Bertelsen
%--------------------------------------------------------------------------
%This program is free software; you can redistribute it and/or
%modify it under the terms of the GNU General Public License
%as published by the Free Software Foundation; either version 2
%of the License, or (at your option) any later version.
%
%This program is distributed in the hope that it will be useful,
%but WITHOUT ANY WARRANTY; without even the implied warranty of
%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%GNU General Public License for more details.
%
%You should have received a copy of the GNU General Public License
%along with this program; if not, write to the Free Software
%Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
%USA.
%--------------------------------------------------------------------------
%CVS record:
%$Id: generateCAcode.m,v 1.1.2.5 2006/08/14 11:38:22 dpl Exp $
%--- Make the code shift array. The shift depends on the PRN number -------
% The g2s vector holds the appropriate shift of the g2 code to generate
% the C/A code (ex. for SV#19 - use a G2 shift of g2s(19) = 471)
g2s = [ 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 ... end of shifts for GPS satellites
... Shifts for the ground GPS transmitter are not included
... Shifts for EGNOS and WAAS satellites (true_PRN = PRN + 87)
145, 175, 52, 21, 237, 235, 886, 657, ...
634, 762, 355, 1012, 176, 603, 130, 359, 595, 68, ...
386];
%--- Pick right shift for the given PRN number ----------------------------
g2shift = g2s(PRN);
%--- Generate G1 code -----------------------------------------------------
%--- Initialize g1 output to speed up the function ---
g1 = zeros(1, 1023);
%--- Load shift register ---
reg = -1*ones(1, 10);
%--- Generate all G1 signal chips based on the G1 feedback polynomial -----
for i=1:1023
g1(i) = reg(10);
saveBit = reg(3)*reg(10);
reg(2:10) = reg(1:9);
reg(1) = saveBit;
end
%--- Generate G2 code -----------------------------------------------------
%--- Initialize g2 output to speed up the function ---
g2 = zeros(1, 1023);
%--- Load shift register ---
reg = -1*ones(1, 10);
%--- Generate all G2 signal chips based on the G2 feedback polynomial -----
for i=1:1023
g2(i) = reg(10);
saveBit = reg(2)*reg(3)*reg(6)*reg(8)*reg(9)*reg(10);
reg(2:10) = reg(1:9);
reg(1) = saveBit;
end
%--- Shift G2 code --------------------------------------------------------
%The idea: g2 = concatenate[ g2_right_part, g2_left_part ];
g2 = [g2(1023-g2shift+1 : 1023), g2(1 : 1023-g2shift)];
%--- Form single sample C/A code by multiplying G1 and G2 -----------------
CAcode = -(g1 .* g2);
⛄ 运行结果
⛄ 参考文献
[1]周柱,石峰,张尔扬,等.一种GPS接收机级联抗干扰方法[J].信号处理, 2010, 26(9):7.DOI:10.3969/j.issn.1003-0530.2010.09.010.