%hPositioningPlotCorr Plot eNodeB correlation
%   hPositioningPlotCorr(ENB,CORR,SR) plots the correlation of each eNodeB
%   in CORR given a sampling rate SR. ENB is a cell array of eNodeB
%   configurations.

%   Copyright 2011-2016 The MathWorks, Inc.

function hPositioningPlotCorr(enb,corr,sr)

    colors = hPositioningColors();
    figure;
    hold on;
    
    nCells = numel(corr);
    % Plot correlation for each eNodeB
    t=(0:length(corr{1})-1)/sr;
    legendstr = cell(1, 2*nCells);
    for i=1:nCells
        color=mod(i-1,numel(colors))+1;
        plot(t, abs(corr{i}), colors{color}, 'LineWidth', 2);
        legendstr{i} = sprintf('NCellID=%d', enb{i}.NCellID);
    end
  
    % Plot markers are correlation peaks
    for i=1:nCells
        color=mod(i-1,numel(colors))+1;
        c=abs(corr{i});
        j=find(c==max(c), 1);
        plot(t(j), c(j),strcat(colors{color}, 'o'), 'MarkerSize', 5, ...
            'MarkerFaceColor', colors{color}, 'LineWidth', 2);
        legendstr{nCells+i} = sprintf('enb%d', i);
    end
    legend(legendstr);
    xlabel('Time (s)');
    ylabel('Absolute value');
    title('PRS correlations for detected cells at UE location');
end
