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

📄 signalgenerator.m

📁 包括载波跟踪和伪码相位跟踪
💻 M
字号:
%%产生输入中频数据
function   [signal,signal_noise]=SignalGenerator(EmulateIndex,inputcode,fs,Ts,fi,delay_time,fd,SNR,Bandwidth,code_cycle,sigma_n,f0,N)

%42位查表,低32位为查找表相位值,高10位为码片值
nb=42;             %查找表位数 
fre_nb=2^nb;    
fre_nb_low=2^32;   %查找表的低32位
fre_nb_high=2^10-1;  %查找表的高10位
NCO_phase=0;%载波NCO相位为0
NCO_fre=fre_nb_low/fs; %单位频率对应的频率字
    
%码延时转换为相应的查找表初始相位
time_phase=-(delay_time*fs)*(code_cycle*(1+fd/f0))*NCO_fre;

%码查找表初始相位 从1003开始
global Fre_acumulator;

if ( 1 == EmulateIndex )
    Fre_acumulator = time_phase;
end


% Fre_acumulator=Phase_NCO_init;  %为了使伪码相位连续,使频率字累加初始值等于上一次调用的剩余相位值
L_min=(EmulateIndex-1)*N+1;   %调用此段数据的最小值点和最大值点
L_max=EmulateIndex*N;
for loop_N=1:N
    t_pass=Ts*(loop_N+L_min-1);       
    PN_code_freq=code_cycle*(1+fd/f0);  %存在多普勒时的码率

    PN_Fre_word=PN_code_freq*NCO_fre; %码频率字
    
    Fre_acumulator=Fre_acumulator+PN_Fre_word;   %频率字累加
    Fre_acumulator=mod(Fre_acumulator,fre_nb_low*fre_nb_high);

    %查找对应的码片值
    PNcode_index=fix(Fre_acumulator/fre_nb_low);    
    PNcode_index=mod(PNcode_index,fre_nb_high)+1;
    Code_samp(loop_N)=inputcode(PNcode_index);
    %载波n
    carrier(loop_N)=cos(2*pi*(fi+fd)*Ts.*(loop_N+L_min-1));
end

[Gauss_Noise_NB,Noise_NB_Power] = NB_GaussNoise(sigma_n,N,Bandwidth,fs,fi);
Gauss_Noise_NB(find(Gauss_Noise_NB>3*sigma_n))=3*sigma_n;  %限幅
Gauss_Noise_NB(find(Gauss_Noise_NB<-3*sigma_n))=-3*sigma_n;  %限幅
%%%信号幅度的计算
A = sqrt(2*Noise_NB_Power*10^(SNR/10));      % 接收的数字中频信号的幅度
%输出信号
signal=A*Code_samp.*carrier+Gauss_Noise_NB;
signal_noise=Gauss_Noise_NB ;%只有噪声的情况

% % 没有噪声情况
% signal=A*Code_samp.*carrier;
% signal_noise=zeros(size(Gauss_Noise_NB)) ;%只有噪声的情况





    

⌨️ 快捷键说明

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