⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sim_samples_raquet.m

📁 Simple GPS Simulation with RINEX Data
💻 M
字号:
function [signal, noise] = sim_samples(snr, prn, sample_times, data_bits, frequency)

ca_code=generateCAcode(prn);
A=1;
sampled_ca_code=create_code_samples(ca_code, 1.023E6, sample_times);
sampled_data_bits=create_code_samples(data_bits, 50, sample_times);

sampled_ca_code = match_vector_orientation(sampled_ca_code, sample_times);
sampled_data_bits = match_vector_orientation(sampled_data_bits, sample_times);

signal = A*sampled_ca_code.*sampled_data_bits.*cos(2*pi*frequency*sample_times);

Pn = A^2/(2*snr);
noise=randn(size(signal))*sqrt(Pn);

function code_samples = create_code_samples(code_sequence, chipping_rate, time_vec)
%function code_samples = create_code_samples(code_sequence, chipping_rate, time_vec)
%
% This function calculates the sampled version of the specified
% code_sequence.  If the time_vec exceeds the length of the sequence, it is
% assumed that the code_sequence repeats, and the samples are created
% accordingly

% Generate code sequence
code_index=mod(floor((time_vec)*chipping_rate),length(code_sequence))+1;

% Correct for 1023 mod 1023 which returns 0 but should be 1023
code_index(find(code_index==0))=length(code_sequence);

code_samples=code_sequence(code_index);


function vec_matched = match_vector_orientation(vec, vec_to_match)
%function vec_matched = match_vector_orientation(vec, vec_to_match)
%
% Returns vec_matched, which contains the same elements as vec, except that
% it is made to match vec_to_match in terms of whether or not it is a row
% or column vector

vec_orientation = diff(size(vec)) > 0;
vec_to_match_orientation = diff(size(vec_to_match)) > 0;

if vec_orientation == vec_to_match_orientation
    vec_matched = vec;
else
    vec_matched = vec';
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -