%% Example 'GpsMultiCorrelator' #3: Generation of energy matrices resulting from non-coherent integrations with different periods% % Generation of energy matrices resulting from the accumulation of non-coherent correlation results, over different periods, between:% - A received signal including a GPS signal,% - A local signal matching in terms of PRN, Doppler and code phase.% ParametersSamplingPeriod = 100e-9;CarrierFrequency = 0;PRN = 3;CN0 = 45*10;Doppler = 0;CodePhase = 0;Duration = 25e-3;% Creation of 'GpsSignals' objectGPS = ... GpsSignals('SamplingPeriod', SamplingPeriod,... 'CarrierFrequency', CarrierFrequency,... 'NextValues', 'replace',... 'PRN', PRN,... 'CN0', CN0,... 'Doppler', Doppler,... 'CodePhase', CodePhase);% Creation of 'GpsMultiCorrelator' objectMultiCorrelator = ... GpsMultiCorrelator('SamplingPeriod', SamplingPeriod,... 'CarrierFrequency', CarrierFrequency,... 'FilterFrequencies', -4000:500:+4000-500,... 'CorrelatorCodePhases', -4:0.5:+4-0.5,... 'PRN', PRN,... 'Doppler', Doppler,... 'CodePhase', CodePhase,... 'CodePhaseIncrement', 0,... 'NonCoherentIntegrationPeriod', 5e-3); for n = 1:6 % Signal duration/non-coherent integration period Duration = n*5e-3; % Update of GPS signals GPS.update('Duration',Duration); % Setting of non-coherent integration period MultiCorrelator.set('NonCoherentIntegrationPeriod',Duration); % Correlation MultiCorrelator.correlate(GPS.Values); end% FigureFigure = ... figure('Color','w','Name','');Axes = subplot(4,1,1:3,'Parent', Figure,'NextPlot','Add');% Display of energy matricesM = numel(MultiCorrelator.EnergyMatrices);for m = 1:M [CorrelatorCodePhases_,FilterFrequencies_] = meshgrid(MultiCorrelator.EnergyMatrices(m).CodePhases,MultiCorrelator.EnergyMatrices(m).Frequencies); surf(Axes,CorrelatorCodePhases_,FilterFrequencies_,MultiCorrelator.EnergyMatrices(m).Matrix,MultiCorrelator.EnergyMatrices(m).Matrix,... 'FaceColor','Interp','EdgeAlpha',0.75,'FaceAlpha',(M-m+1)/(M+1));end% Display of maximumMaxima = cellfun(@(M)max(M,[],'all'),{MultiCorrelator.EnergyMatrices.Matrix});m = find(eq(Maxima,max(Maxima)));[i,j] = find(eq(MultiCorrelator.EnergyMatrices(m).Matrix,Maxima(m)));text(MultiCorrelator.EnergyMatrices(m).CodePhases(j),MultiCorrelator.EnergyMatrices(m).Frequencies(i),MultiCorrelator.EnergyMatrices(m).Matrix(i,j),... {'Energy maximum',... sprintf('MultiCorrelator #%u: %+.fchip',j,MultiCorrelator.EnergyMatrices(m).CodePhases(j)),... sprintf('Filter #%u: %+.fHz',i,MultiCorrelator.EnergyMatrices(m).Frequencies(i)),... '\downarrow'},... 'HorizontalAlignment','center',... 'VerticalAlignment', 'bottom');% Display of informationsview(Axes,-30,30);T = [MultiCorrelator.EnergyMatrices(:).IntegrationTime];title({'Energy matrices',... sprintf('(%u matrices x %u filters x %u correlators,',... numel(MultiCorrelator.EnergyMatrices),... numel(MultiCorrelator.EnergyMatrices(1).Frequencies),... numel(MultiCorrelator.EnergyMatrices(1).CodePhases)),... sprintf('integration period: %s %sms)',num2str(1e3*T(1:end-1),'%.f, '),num2str(1e3*T(end),'%.f'))});xlabel('Code phase [chip]');ylabel('Frequency [Hz]');zlabel(sprintf('Energy - PRN%u',PRN));% ColorbarMap = hsv;Map = Map(1:find(diff(Map(:,1))>0,1,'first'),:);Map = [Map;0 0 1];colormap(fliplr(Map));Colorbar = colorbar;Colorbar.Label.String = 'Energy';Colorbar.Location = 'EastOutside';% Display of maximaAxes(2) = subplot(4,1,4,'Parent',Figure,'NextPlot','Add','Box','on','Xgrid','on','Ygrid','on');plot(Axes(2),1e3*T,Maxima,'.-');set(Axes(2),'Xlim',[min(1e3*T) max(1e3*T)]);title('Energy maximum vs non-coherent integration period')xlabel('Non-coherent integration period [ms]');ylabel('Energy maximum');% Update of axesset([Axes';findall(Axes,'type','text')],'fontsize',9);% Main titlesgtitle('Energy matrices and non-coherent integration period',... 'FontSize',11,'FontWeight','Bold');% Maximization of figureFigure.WindowState = 'maximized';