%hPlotCSIRSMeasurements plots CSI-RS based RSRP/RSSI/RSRQ measurements

%   Copyright 2019 The MathWorks, Inc.
function hPlotCSIRSMeasurements(meas)

    numRes = numel(meas.RSRP);
    xTickLabels = {};
    for idx = 1:numRes
        xTickLabels = [xTickLabels {['CSI-RS resource #' num2str(idx-1)]}]; %#ok<AGROW>
    end

    measType = {'CSI-RSRP','CSI-RSSI','CSI-RSRQ'};
    measVal = {meas.RSRPdBm, meas.RSSIdBm, meas.RSRQdB};
    measUnits = {'dBm','dBm','dB'};

    for measIdx = 1:3
        figure()
        values = measVal{measIdx};
        baseVal = 0;
        if ~any(values > 0)
            baseVal = floor(min(values));
        end
        b = bar(values,'FaceColor','#EDB120','BaseValue',baseVal);
        xticklabels(xTickLabels);

        xtips = b.XEndPoints;
        ytips = b.YEndPoints;
        for i = 1:numel(xtips)
            text(xtips(i), ytips(i), sprintf(['%0.2f ' measUnits{measIdx}],values(i)), ...
                'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Top');
        end
        ylabel([measType{measIdx} ' in ' measUnits{measIdx}]);
        title([measType{measIdx} ' measurements (in ' measUnits{measIdx} ')'])
    end
end