I'm trying to analyze GPS L1 C/A signal on MATLAB. I could generate the PRN codes(binary signals). After I add NAV Data to the PRN code using modulo 2, I need to modulate it using BPSK. I also could it(I am using IF_freq=20 instead of real frequenc=1.5GHz).
For getting the PSD graph of the modulated signal, I correlated it by itself and got FFT of the correlation. But my graph seems wrong, can someone explain why I am getting this graph?
My MATLAB code:
prn_1_40ms = repmat(prn_1,1,40); %%PRN 1 for 40ms prn_2_40ms = repmat(prn_2,1,40); %%PRN 2 for 40ms [PSK_signal,org_data,time_bpsk] = BPSK_Modulation(prn_1); correlated_sig=xcorr(PSK_signal,'normalized'); Fs=400; PSD=abs(fftshift(fft(correlated_sig))); freq = -Fs/2:Fs/length(PSD):Fs/2-(Fs/length(PSD)); figure; subplot(2,1,1); plot(correlated_sig); subplot(2,1,2); plot(freq,PSD); function [mod_sig, org_sig, time_out] = BPSK_Modulation(data) %%For BPSK Modulation %%https://www.mathworks.com/matlabcentral/fileexchange/30582-binary-phase-shift-keying % Enter the two Phase shifts - in Radians % Phase for 0 bit P1 = 0; % Phase for 1 bit P2 = pi; freq_L1=20; %Instead of using L1 real frequency, we use lower frequency %to make the calculation easier and make the details more appear on the %graph freq_Samp=freq_L1*50; %Sampling frequency have to be at least double the %carrier frequency. Higher sampling, more resolution. f=freq_L1; t=0:1/freq_Samp:1; time=; PSK_signal = ; Digital_signal = ; for ii = 1: 1: length(data) % The FSK Signal PSK_signal = [PSK_signal (data(ii)==0)*cos(2*pi*f*t + P1)+... (data(ii)==1)*cos(2*pi*f*t + P2)]; % The Original Digital Signal Digital_signal = [Digital_signal (data(ii)==0)*... zeros(1,length(t)) + (data(ii)==1)*ones(1,length(t))]; time = [time t]; t = t + 1; end mod_sig = PSK_signal; org_sig = Digital_signal; time_out = time; end