function [codephase,frequency] = acquisitionConvolution(svnum) % Performs acquisition on collected data % Searches for the satellite with number svnum % Returns the code phase and the coarse frequency of the signal % ***** initial conditions ***** load data.mat x=double(data'); fs=11.999e6; % sampling freq ts=1/fs; % sampling time n=fs/1000; % data pt in l ms nn=[0:n-1]; % total no. of pts fc0=3.563e6; % center freq without Doppler % ***** Reads code with 1024 different phases filename=sprintf('gold%i.mat',svnum); load(filename); code=double(code(1,:)); % ***** DFT of C/A code codefreq = conj(fft(code)); for i=1:41 fc(i) = fc0 + 0.0005e6*(i-21); expfreq=exp(j*2*pi*fc(i)*ts*nn); sine= imag(expfreq); % generate local sine cosine= real(expfreq); % generate local cosine I = sine.*x; Q = cosine.*x; IQfreq = fft(I+j*Q); convcodeIQ = IQfreq .* codefreq; result(i,:) = abs(ifft(convcodeIQ)).^2; end [peak codephase]=max(max(result)); [peak frequency]=max(max(result')); frequency = fc(frequency); codephaseChips = round(1023 - (codephase/11999)*1023) gold_rate = 1.023e6; % Gold code clock rate in Hz ts=1/fs; tc=1/gold_rate; b=[1:n]; c=ceil((ts*b)/tc); figure(1) x_axis=c; y_axis=fc/1e6; s=surf(x_axis,y_axis,result); set(s,'EdgeColor','none','Facecolor','interp'); axis([min(x_axis) max(x_axis) min(y_axis) max(y_axis) min(min(result)) max(max(result))]); caxis([0 max(max(result))]); xlabel('Code Phase [chips]'); ylabel('Frequency [MHz]'); zlabel('Magnitude'); text=sprintf('SVN %i',svnum); title(text);