You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: getRMSE.m
    path of file: ./repos/5G_based_System_level_Integrated_Sensing_and_Communication_Simulator/+sensing/+postProcessing
    
    the code of the file until where you have to start completion: function radarEstRMSE = getRMSE(radarEstResults, radarEstParams)
% Calculate the root mean squre error (RMSE) of estimation results
%
% Author: D.S Xue, Key Laboratory of Universal Wireless Communications,
% Ministry of Education, BUPT.
    
    %% Parameters
    % The estimation result is seen as a non-detection
    % when the corresponding error exceeds the threshold value.
    rngDetThreshold = radarEstParams.rRes;
    
    % antenna array type
    isUPA = isa(radarEstParams.antennaType, 'phased.NRRectangularPanelArray'); 


    
function radarEstRMSE = getRMSE(radarEstResults, radarEstParams)
% Calculate the root mean squre error (RMSE) of estimation results
%
% Author: D.S Xue, Key Laboratory of Universal Wireless Communications,
% Ministry of Education, BUPT.
    
    %% Parameters
    % The estimation result is seen as a non-detection
    % when the corresponding error exceeds the threshold value.
    rngDetThreshold = radarEstParams.rRes;
    
    % antenna array type
    isUPA = isa(radarEstParams.antennaType, 'phased.NRRectangularPanelArray'); 

    %% Calculate errors
    % real & estimated values
    rngReal = extractfield(radarEstParams.tgtRealPos, 'Range')';
    velReal = extractfield(radarEstParams.tgtRealPos, 'Velocity')';
    eleReal = extractfield(radarEstParams.tgtRealPos, 'Elevation')';
    aziReal = extractfield(radarEstParams.tgtRealPos, 'Azimuth')';
    
    rngEst = extractfield(radarEstResults, 'rngEst');
    velEst = extractfield(radarEstResults, 'velEst');
    if isUPA
        eleEst = extractfield(radarEstResults, 'eleEst');
        aziEst = extractfield(radarEstResults, 'aziEst');
    else
        aziEst = extractfield(radarEstResults, 'aziEst');
    end